Questions tagged [php]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
13 views

Configuring Nginx with Azure Linux Web App (PHP 8, Craft 4)

Attempting to update an Azure Linux Web App to Craft 4. So I updated the Linux Web App to PHP 8. But now it’s using Nginx instead of Apache (would have been nice to know they change that when you ...
user avatar
  • 138
0 votes
1 answer
79 views

What's the correct way to check that an asset file exists?

If I have an asset resource, loaded successfully from the database, whose corresponding file no longer exists on its Volume (irrespective of Volume type), what is the best way to find out if the file ...
user avatar
  • 33
3 votes
1 answer
54 views

.all() — Looping through element queries directly has been deprecated

This is very nearly a duplicate question but I can't figure out where to insert .all() to execute my element query. I'm still asking because I may be messing up php, function or filter syntax ...
user avatar
  • 65
1 vote
2 answers
133 views

Can’t run Craft CMS :( Your server doesn’t meet the following requirements to run Craft CMS:

Can’t run Craft CMS :( Your server doesn’t meet the following requirements to run Craft CMS: The Mcrypt extension is required. Please talk to your host/IT department about upgrading your server. I am ...
user avatar
2 votes
1 answer
50 views

Craft Commerce: Multiple redirect submit buttons from cart form (checkout/update cart) without ajax

I'm building a basic cart page in Craft 3.7.37 with Commerce 3.4.12. The /store/cart page has a <form> with the line items in the cart next to an <input /> to change quantity and one to ...
user avatar
  • 65
0 votes
0 answers
25 views

Admin CP requests Http rather than https so browser gives non secure and javascript doesn't load

I have a weird issue happening and looking for any advice or tricks to try. I currently have an AWS setup for my site but I don't have control of aws as that is handled by a different internal ...
user avatar
2 votes
1 answer
85 views

Security Key Not Loading from Environment: Next Twig\Error\RuntimeError: craft\web\Request::cookieValidationKey must be configured with a secret key

Our new Craft CMS instance in the AWS cloud won't load the security key from an environment variable. (We do not use a .env file.) $ curl http://localhost/actions/app/health-check An internal server ...
user avatar
0 votes
0 answers
31 views

Error - Job must be a JobInterface instance instead of __PHP_Incomplete_Class

When I try to run a custom queue job on craftcms, it fails every time and I got this error Job must be a JobInterface instance instead of __PHP_Incomplete_Class, I'm pretty new to craftcms and even ...
user avatar
  • 11
0 votes
0 answers
41 views

Path issue shows with composer installing via MAMP on macOS

When I have tried to install composer for laravel 8 on localhost MAMP I have gotten this message in command line (terminal): -bash: /Applications/MAMP/bin/php/php7.4.16/bin/php: No such file or ...
user avatar
4 votes
1 answer
31 views

Identify event origin (e.g. via admin vs module code)?

When using Craft Event triggers in PHP (e.g. Event::on), is there any event metadata that can tell where the event originated from? E.g. if it was triggered from an admin action, or if it was ...
user avatar
  • 438
0 votes
0 answers
23 views

Copy reset password url not showing for admin

I am trying to reset the password of a couple of users and running into a couple of issues. First when I try to send reset password email I get an internal server error undefined variable loginName. ...
user avatar
0 votes
0 answers
174 views

Error: "The Process class relies on proc_open, which is not available on your PHP installation"

Has anyone experience this error when running 'composer install' command via C-Panel Terminal? "The Process class relies on proc_open, which is not available on your PHP installation"
user avatar
1 vote
1 answer
94 views

Check for existing jobs in queue

Is it possible in code to search for a job/list out all jobs? I have built a plugin that scans an external API and I want to scan on an interval as well as allow the user to fire off a manual scan. I ...
user avatar
  • 11
2 votes
2 answers
151 views

How to get multiple image array using API or PHP query

This is a single asset field to upload multiple images so how to get all images using the query. I have three images here but I am getting one image using this code $home = \craft\elements\Entry::...
user avatar
0 votes
0 answers
59 views

getDirtyFields returning more results than expected

I have a module that sends an email whenever a specific entry field is updated. Everything is working fine except that the field is being passed to the dirtyFields array even if it has not been ...
user avatar
1 vote
1 answer
23 views

how to write db-commands on custom table (PHP syntax) inside twig file?

if i have a custom table (ct_table) and i have to use MySQLi commands on it using the PHP syntax, it won't work if i put the PHP snippets inside a twig file. So are there any tools or official methods ...
user avatar
  • 125
1 vote
1 answer
89 views

PHP Parse Error During Installation

Installing Craft on MediaTemple. Ran the server check and it came back green except for the memory allocation, which I increased in the PHP.ini file. Ran the composer install script and it runs fine ...
user avatar
  • 176
1 vote
1 answer
131 views

Set parent-child relationship in PHP

I'm new to Craft but long time back-end php programmer. I'm trying to assign a parent-child (a ENTRY type to another ENTRY type) relationship in php based on some business rules. I've got my child ...
user avatar
2 votes
1 answer
126 views

How to handle custom PHP logic in CraftCMS

I come from a "traditional" PHP paradigm where views are mixed with processing logic. And now switching from WordPress to CraftCMS (which so far is a beautiful experience) I am having ...
user avatar
0 votes
0 answers
48 views

EnupalSnapShot don't work

I recently updated my plugin license (enupalsnapshot), and it turns out that now it doesn't want to work anymore. I use the option to generate PDF from the URL and it returns the following error in ...
user avatar
  • 1
0 votes
0 answers
23 views

Variable scope in Element API

I am using the Craft Element API and getting a bit muddled over PHP variable scopes. I was hoping if someone could please explain why this does not work: $isProd = App::env('ENVIRONMENT') === '...
user avatar
  • 33
1 vote
2 answers
395 views

What server settings would be responsible to debug "The process has been signaled with signal 9" errors?

We're running Craft in an AWS environment that is configured using CentOS 7, Apache 2.4.x, PHP 7.4.x, PHP-FPM and we've noticed many of our queued tasks fail (sometimes only 8-10 minutes into the ...
user avatar
0 votes
0 answers
68 views

How to print variables inside a PHP Event?

I'm trying to work with the Sprout Forms events to grab a variable from the form and add it to a filename also uploaded through the same form. I am extremely stuck and so far I can't even confirm ...
user avatar
1 vote
1 answer
69 views

Access env variables in custom php files

Craft Version 3.2 PHP Version 7.2 Below is my folder structure: Root - Other Craft Folder - Web - Services - Db.php - env file I want to read the connection string of the SQL ...
user avatar
3 votes
1 answer
204 views

Update from 3.3.4.1 to 3.6.11.2 advice

What is the best way to do this? I also have a number of plugins that all need updating from the same time period. I don't think any of the breaking changes affect anything I've done, but I wonder/...
user avatar
2 votes
1 answer
130 views

Force craft to do another job (queue) and pause the current one

I'm currently working on a plug-in for Craft. I have to work with a lot of data and, some steps are slow. So that's why I added them to a job system. This job is doing a lot of stuff. That job is ...
user avatar
1 vote
0 answers
82 views

How to programatically (e.g. in a custom a plugin) create a Discount Code? (Craft Commerce)

I've been working on some custom plugins recently to handle various bits of API functionality for the project I'm working on, and I'm now roughly familiar with Craft's OO approach to carrying out this ...
user avatar
  • 111
0 votes
0 answers
64 views

Has anyone experienced any cURL error 28: timeout errors using php 7.4 and craft 3.5?

So the site was working on a new server. But over night I am now seeing the site hang and not load. When it does give an error it gives a cURL error 28 with connection timed out on various resources ...
user avatar
  • 2,023
1 vote
1 answer
156 views

Trouble running craft with docker

I'm trying to set up craft to run with the docker images provided here. When I run docker-compose build, it gets through a few lines in the Dockerfile and then stops with an invalid reference error ...
user avatar
1 vote
2 answers
69 views

How to develop API with TWIG

I want to develop an API within Twig template that will have PDO implementation to get data. My application will be using content through CRAFT. Is it possible to develop API with TWIG template? ...
user avatar
1 vote
1 answer
118 views

Issue on new craft (craftcms3) setups: vendor Twig can't read system variable

After installing craft through composer, setting up the database and running craft setup, I have a craft application ready to go. When I go to settings/general, I always get a crash with following ...
user avatar
  • 113
2 votes
1 answer
299 views

Use of App::env() compared to getenv() since Craft 3.4.18

I've noticed since Craft 3.4.18 there is a App::env() function from craft\helpers\App::env(). This was created from the discussion here it seems: https://github.com/craftcms/cms/pull/5893 It seems ...
user avatar
  • 1,031
1 vote
1 answer
94 views

How to get all Element Types?

From within a plugin/module using PHP; is there a way to query all element types being used, including custom elements? I know in the elements database table there is a type column that I could ...
user avatar
  • 2,265
1 vote
2 answers
614 views

mkdir(): Permission denied

I have an old craft 2 installation. When I want to go to the frontend I get: mkdir(): Permission denied 745 { 746 if ($permissions == null) 747 { 748 $permissions = ...
user avatar
  • 3,664
1 vote
1 answer
149 views

PHP error when trying to access dates in Sprout Reports

Basic Sprout Report here, settings page: {{ forms.dateTimeField({ label: "Start Date"|t, instructions: "The start date of the date range you wish to display in your report."|t, ...
user avatar
  • 608
4 votes
1 answer
298 views

Is there a way to compare what has changed on an entry while it's being saved?

I'm taking my first baby steps into the php side of Craft, and my php experience in general is extremely fledgling. But I'm pretty much forced to create a module for a project I have, so here I am ...
user avatar
  • 283
1 vote
1 answer
185 views

Get a key value from a JSON asset in PHP

I'm using the Apple News plugin to try and display a tweet that's been added as a JSON asset in a matrix field. The JSON looks something like this { "title": "https://twitter.com/...
user avatar
  • 251
1 vote
1 answer
15 views

How do entry elements render a default string but also return an object at the same time?

So this is more of a PHP question than a Craft question, but the only example I can offer is one I've seen in Craft. {{ craft.entries.id(4).one() }} Returns a simple string like: "About Page"...
user avatar
  • 2,265
1 vote
1 answer
75 views

Why does Bootup.php run with PHP 5.4.16 from with Craft script but PHP 7.4.10 from the terminal command line?

This is a problem encountered apparently by a lot of users when installing from the Craft setup/install files from the Craft web site. PHP Warning: Unsupported declare 'strict_types' in /var/craft/...
user avatar
1 vote
1 answer
40 views

LineItems not showing in CMS

I'm scratching my head. My orders are shown perfectly except for one product. I have no idea why so I looked at the Order object before saving and I can't seem to figure out why he won't show the ...
user avatar
1 vote
2 answers
537 views

Site moved to new server - Error 500

I inherited a site running craft and I was asked to move it to my server to host it. The other developer zipped the files and made a database dump for me. Usually, when I move a site, they have Cpanel ...
user avatar
2 votes
1 answer
421 views

Craft Nitro PHP extension ext-zip * is missing

I'm not particularly tech minded so MAMP has served me well for a good while. However I more recently decided to give Craft Nitro a try. I got everything (Multipass and Nitro) set up really easy. I ...
user avatar
  • 1,173
0 votes
0 answers
41 views

Website Stuck on Load after few requests

I'm facing a weird issue here. I'm developing a CraftCMS based website and all seem to be working fine, until after a few requests (clicking around 4 ~ 5 requests) the website seem to keep loading and ...
user avatar
1 vote
1 answer
88 views

Updates always error out

Every time I try to run an update, I get these errors. Installing plugins won't work either. I'm using Media Temple / Grid server hosting. I've increased the file size limits in php.ini as well. But I'...
user avatar
1 vote
1 answer
78 views

Put SEO and Twitter card Meta tags in the Head section prior the render of the template

I need to put some <meta /> tags in the <head /> section of the html document prior the rendering of the template. I would like to know how can I achieve this? I also need to query an ...
user avatar
1 vote
1 answer
108 views

Error when trying to update Craft

I'm pretty new to CraftCMS and am trying to install updates for a client. I am getting this error and I don't really know what it means. Any help of brief explanation for this would be appreciated. ...
user avatar
  • 113
1 vote
1 answer
3k views

The requested URL was not found on this server. Apache/2.4.18 (Ubuntu) Server at localhost Port 80

The frontend just work fine. But when I call the backend http://localhost/craft3/web/admin/dashboard/ or http://localhost/craft3/web/admin/ I get the error requested URL was not found on this server. ...
user avatar
  • 31
1 vote
1 answer
31 views

Setting relative path to ElementAPI in PHP

I need a few small bits of data from Craft in a PHP file. It’s a really small task, so I don’t want to delve into writing plugins or anything hardcore. It seemed to me the simplest way to approach it ...
user avatar
  • 176
2 votes
1 answer
142 views

Get currentSite.handle in Element API

I need to get the currentSite in Element API. How can this be achieved? Is it as a slug in the endpoint URL? or as a Query param? Here is the current code: <?php use craft\elements\Entry; use ...
user avatar
  • 23
0 votes
0 answers
156 views

How to load more entries of a category on that category's page with Element API?

Following up on previous questions of mine: How to use multiple different instances Element API "Load More" button? I have a website that utilizes the "load More" (button) method ...
user avatar

1
2 3 4 5 6