Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [php]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
2 answers
73 views

Unable to find custom template when using a console controller inside a module

I'm creating my first module. Inside this module, I check a few entries for some conditions, and if all conditions are met, I want to send out a personal email. Everything worked, but I wanted to ...
Arno Ramon's user avatar
1 vote
1 answer
232 views

PHPdotEnv upgrade not working

Updating my Craft CMS website to Craft 3.8 on PHP 8.1 yielded the first of its kind: the fatal deprecation error that would not allow the migration to continue. Turns out, PHPdotEnv v 2.8 is too old: ...
Caroline Blaker's user avatar
0 votes
1 answer
55 views

Error on plugin settings page: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

I've installed the latest CraftCMS version via composer. When I'm visiting the plugins settings page (/web/admin/settings/plugins), I get the following error message: preg_replace(): Passing null to ...
Odin's user avatar
  • 1
2 votes
1 answer
97 views

How to Escape a Query Parameter

Extremely not a PHP developer here but trying to set up a simple API with Element API. I've got the basics working to filter my entry results based off of a query URL parameter: use craft\elements\...
kmgdev's user avatar
  • 1,179
1 vote
1 answer
139 views

Updated to PHP version 8.1.22 and one of my Craft 3 sites is getting a critical error

I upgraded my server to PHP 8.1.22 in order to start a new Craft 4 site, and one (but not all) of my existing Craft 3 (3.6.17) sites is giving me the following error. How do I resolve this error? See ...
Justin Kendall's user avatar
0 votes
0 answers
94 views

Craft cms[4.x]: Frontend Site broke after performing a feed with feed me

On our last data migration from wordpress i import through feed me all the data but the postDates. 31-08-2023 11:12 I imported a csv file in feed me with all the posts content including the postDates ...
Adam Fernandez's user avatar
1 vote
1 answer
70 views

Excluding entries in an entry query with an array of IDs (PHP)

This seems more like a PHP question than a Craft CMS question, but since it's related to an entry query I'm trying to create I figured someone from the Craft community might know. I'm having trouble ...
Dalton Rooney's user avatar
0 votes
1 answer
30 views

Site breaking when I call a custom module up on app.php file

My Craft CMS version 3 site is breaking when I boostrap a custom module up on app.php file. The code looks like this: <?php use craft\helpers\App; return [ 'id' => App::env('APP_ID') ?: '...
Sean G's user avatar
  • 11
2 votes
1 answer
187 views

How to use ajax call to retrieve data from craft cms entries to use in php application

I'm building a static webpage with php and Javascript. I have setup all my data in craft cms entries. I want to use ajax to retrieve the data from craft and just display it on my webpage. How do I do ...
Alyx's user avatar
  • 23
1 vote
1 answer
61 views

Craft CMS 2 - Exporting entity issue

I installed this https://github.com/boboldehampsink/export plugin but getting error during exporting entities regarding to "count(): Parameter must be an array or an object that implements ...
Nik Dev's user avatar
  • 13
1 vote
2 answers
102 views

How to programatically disable an entry for a specific site

We have a multi-site setup where we would like to disable a bunch of entries on the primary site only. They entries should still be enabled for the second site. I'm working on a migration that looks ...
Dalton Rooney's user avatar
1 vote
1 answer
218 views

After upgrade from Craft 3 to 4: frontend error: Array to string conversion

After upgrading from Craft 3 to Craft 4, the backend is accessible but the frontend displays the error: PHP Warning – yii\base\ErrorException Array to string conversion And points to many files: ...
BrokenCode's user avatar
1 vote
1 answer
60 views

Job queue always failed to sync data into api/graphql with Getting unknown property of service

i have build a module to send entry value into a graphql mutation. so far running and succesfully, now with craft 4 (actually as 4.4.0), i plan to use job queue of craft. i add into queue before sync ...
Arham's user avatar
  • 11
3 votes
1 answer
294 views

What does the triple operator ??? do in this case?

I know what the null coalescing operator (??) does. I have an example here with 3 operators and I am unsure what it does? Here is an example that I came across in a script I am trying to debug: {% set ...
BrokenCode's user avatar
0 votes
1 answer
29 views

How to get event target asset in PHP module

I have been implementing my PHP module for Craft website. Could I ask how can I get the target asset in this if-statement? protected function initRestrictUserIndex() { Event::on( ElementQuery::...
Kota.M's user avatar
  • 423
1 vote
1 answer
110 views

Set asset volume dynamically via module depending on uploaded file kind

I'm trying to set the asset volume dynamically for new assets, using a module. I would like the volume to be based on the asset's file kind – in my case, automatically putting MP4s into a 'Videos' ...
Josh Harrison's user avatar
1 vote
1 answer
145 views

How can I best add additional fields to the Address form during the checkout

I want my customers to enter their date of birth and place of birth during the checkout. Do I have to overwrite the Address commerce model somehow? (\craft\commerce\models\Address). Something else I ...
Rayco's user avatar
  • 11
1 vote
1 answer
174 views

Can I detect if the event is saving entry?

I have been implementing my own module like this; protected function myFunction() { Event::on( ElementQuery::class, ElementQuery::EVENT_BEFORE_PREPARE, function(Event $event) { ...
Kota.M's user avatar
  • 423
0 votes
0 answers
26 views

Register own FieldType in Craft 3.x

I have the following struggle. I tried to register my FieldType in my init function of the module.php. Event::on( Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, function(...
Jonathan Fuchs's user avatar
0 votes
1 answer
1k 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 ...
M Smith's user avatar
  • 150
1 vote
1 answer
357 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 ...
tomkiss's user avatar
  • 43
3 votes
1 answer
138 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 ...
Yawner's user avatar
  • 65
1 vote
2 answers
565 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 ...
Alex Briones's user avatar
2 votes
1 answer
169 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 ...
Yawner's user avatar
  • 65
0 votes
0 answers
43 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 ...
user1535268's user avatar
2 votes
1 answer
391 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 ...
Micah Henning's user avatar
5 votes
1 answer
84 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 ...
iamkeir's user avatar
  • 468
0 votes
0 answers
829 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"
DieselHashtag's user avatar
1 vote
1 answer
557 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 ...
Henry's user avatar
  • 11
2 votes
2 answers
608 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::...
Santanu Adak's user avatar
2 votes
0 answers
248 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 ...
Jorge Sosa's user avatar
1 vote
1 answer
44 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 ...
Ra3d K's user avatar
  • 125
1 vote
1 answer
419 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 ...
mitrol's user avatar
  • 262
2 votes
1 answer
396 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 ...
Sylvain Tremblay's user avatar
2 votes
1 answer
402 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 ...
Álvaro Franz's user avatar
0 votes
0 answers
70 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 ...
Bruno's user avatar
  • 1
1 vote
2 answers
1k 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 ...
Aaron Bushnell's user avatar
0 votes
0 answers
145 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 ...
JJefferyDev's user avatar
1 vote
1 answer
220 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 ...
Deepak Kale's user avatar
3 votes
1 answer
239 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/...
Paul Frost's user avatar
  • 1,060
2 votes
1 answer
306 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 ...
randomGuy's user avatar
1 vote
0 answers
184 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 ...
MyNotes's user avatar
  • 111
0 votes
0 answers
89 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 ...
Lettie's user avatar
  • 2,033
1 vote
1 answer
323 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 ...
Isabel Sharp's user avatar
1 vote
2 answers
163 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? ...
Deepak Kale's user avatar
1 vote
1 answer
213 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 ...
Recipe's user avatar
  • 113
2 votes
1 answer
866 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 ...
James White's user avatar
  • 1,161
1 vote
1 answer
198 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 ...
Mark Notton's user avatar
  • 2,337
1 vote
2 answers
1k 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 = ...
KSPR's user avatar
  • 3,786
1 vote
1 answer
195 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, ...
4midori's user avatar
  • 656

1
2 3 4 5 6