Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [php]

The tag has no usage guidance.

1
vote
1answer
82 views

Getting PHP Error on upgrade from 3.0.36 to 3.1

I just updated to 3.1 and I'm getting the php error: PHP Notice – yii\base\ErrorException Undefined index: settings It probably has to do with the Cheat Sheet plugin. I deleted that folder in the ...
-1
votes
0answers
22 views

Craft cms writing already expired sessions and cookies

Craft CMS is writing very old cookies which expire in 1969 which are causing, the user to log out everytime when logged in. both the csrftoken and sessionid are given an expiry date of 1969. i tried ...
1
vote
1answer
15 views

Closure in plugin class/ saving and passing a public property

I am struggling with closure and saving a variable. In my class somePlugin i do have a public var $customerId , which should be updated after i execute my setUser() function. To do so i have a setter ...
2
votes
0answers
22 views

How can I get tasks to complete when not logged in to the CP

I've noticed that tasks only run when logged into the admin panel, is there anyway to avoid this? For some context: I have jobs scheduled on a cron to run every 30 minutes, when I log in it seems ...
1
vote
2answers
49 views

Getting fatal error when installing new plugin by hitting memory_limit

I am trying to locally install Craft Typed Link Field from the plugin store and I'm getting this PHP error. I have already upped my memory_limit to 256M within my php.ini file, yet this is claiming ...
1
vote
0answers
38 views

Extending Craft Commerce Purchasable Nav Items

I'm looking to extend Craft Commerce with a custom Purchasable. I'd like to implement this using a module if possible. I've implemented the base class for my new Purchasable and that's all good. ...
1
vote
1answer
26 views

InvalidArgumentException with composer

I need your help, please. At https://docs.craftcms.com/v3/installation.html#step-1-download-craft I have this instruction: "To create a new Craft project, run this command (substituting with the ...
1
vote
2answers
29 views

Craft CMS module composer dependancy

After some research surrounding this I can't seem to fix this issue. So for a project I made a simple module with some variables that simply has to make an OAuth1 call and return some data. The ...
1
vote
1answer
19 views

Craft install failed with error php7 not found, but server has php 7 installed

I'm trying to install a backup from production site which is running craft 3.0.26 to a UAT site. While installing, faced an error regarding PHP versions. Since both the sites are in the same server, ...
1
vote
1answer
37 views

Element-API: Access the first url of an asset array

I have an asset field in my current project with the handle postImage, containing multiple image files. In my element-api endpoint, I wish to access the url of the first file only. I tried the ...
1
vote
1answer
66 views

Is it possible to create a plugin using Python in Craft 2?

I've been searching and trying things for a few days now, but I feel like I'm spinning my wheels. I've got a Python script that reads in a .pptx file, and returns a Dictionary of slides. I've also ...
0
votes
0answers
61 views

Craft 3 zero byte asset upload AJAX

I'm using the upload method like the answer in this overflow post in combination with AJAX & new FormData($(this)[0]). It works fine, but sometimes files (assets5b5207f23605a3.51574157.jpg) have 0 ...
1
vote
1answer
111 views

Q: Call to member function on null - Freeform (Solspace)

I am running Freeform 1.9.0 and I have a small plugin that is supposed to save user submission id's to a custom user field. The plugin returns error when it runs after a new user submits a form though....
1
vote
0answers
165 views

Autocomplete for Visual Studio Code for plugin development

How to achieve autocompletion for Craft 3 for PHP inside Visual Studio Code? I mean, what is required (like installing PHP locally, folder structure etc.) if at all possible? I assume many people who ...
1
vote
1answer
32 views

Composer Issue When Doing exec From a Plugin

Curious if anyone has ever run into this before or may know what's going on here. I'm using the execWidget plugin (https://github.com/marionnewlevant/craft-exec_widget) to run a script from Craft's ...
1
vote
1answer
89 views

Pass custom variable to view

Coming from a Yii2 background, I am accustomed to doing things in an MVC way. I have set up a demo Craft CMS application to have a play around with. I've created a "singles" page (homepage) and got ...
1
vote
0answers
153 views

Element API plugin: searching and working with nested objects

I’m experimenting with the Element API plugin and working with querying the tags of the assets that appear in matrix blocks in a set of entries. Essentially I’m hoping to be able to use a tag in a ...
0
votes
0answers
41 views

How to best run a custom PHP script in craft 3? [duplicate]

I have a php script for displaying delivery tracking information which runs independent from craft. It should run on a craft website on a specific page like so https://mypage.com/tracking/?content=...
3
votes
1answer
62 views

Set SuperTableFields programatically

I'm trying to setup some Global fields in a migration. I'm using the SuperTable Field from verbb which is similar to a matrix field. I'd like to add several rows during migration but can't seem to ...
1
vote
1answer
103 views

Craft 3 Redis configuration error

when following the information for enabling Redis in Craft 3, my site just refreshes to a blank screen with a "Internal server error" generic message. Reviewing the server logs reveals: ...
2
votes
1answer
43 views

Can I send a status message from an external (standalone) PHP script to the Craft engine?

Note: this question pertains to Craft 2 Pro. Craft 3 is not currently an option. What I need to do I have some stand-alone utilities that don't need to exist within the Craft framework, so I would ...
1
vote
1answer
99 views

Receiving PHP Warning on move to Production

I am moving a client site from my staging VPS to my clients preferred hosting. All of Crafts requirements check out just fine: PHP Version 7.0.29 MySQL Version 10.2.12-MariaDB-log However, when ...
4
votes
1answer
273 views

How do I “register” a service in a Craft 3 plugin?

In Craft 2, services were auto-loaded when using the craft()->plugin_serviceName->myMethodName() signature, but it seems like there's a catch in Craft 3, when using the new MyPlugin::getInstance(...
3
votes
0answers
72 views

Update Asset Index in Migration

I'm trying to index some asset volumes that I'm creating in a migration. These are local volumes which may already contain files. I'm hoping to avoid the step where I have to manually update the ...
1
vote
1answer
38 views

What Might Be Causing This Serialization Error?

Craft Pro 3.0.7Notifications Plugin 1.0.6PHP 7.0 In trying to send notifications for new entries that have a checkbox field, we get this error in the logs: 2018-05-14 09:19:32 [192.168.10.1][1][-...
1
vote
2answers
63 views

Specify Redactor config in migration

is it possible to specify the Redactor config file when creating a Redactor field programmatically? I was hoping I could do something like the following but have had no success: $bodyField = $...
1
vote
1answer
68 views

How to create an element query in PHP with custom field names in variables?

I'm trying to dynamically create an element query in PHP where the custom field criteria come from an array of strings. Something like this...? $users = User::find(); $users->group($groupList); ...
0
votes
0answers
86 views

Craft 2: Internal Server Error Undefined variable: loginName when sending password reset email

I have an issue with a Craft 2 site, v2.6.3012 When I hit the "Send password reset email" on a user profile, it fails with Internal Server Error Undefined variable: loginName What would cause that? ...
0
votes
1answer
349 views

'Craft requires PHP 7.0 or later'

I took the manual install route, unzipped the latest Craft version, and edited the .env file with my database settings, but when I direct my browser to /craft/web/index.php I get a plain page with ...
1
vote
1answer
53 views

After switching from PHP 5 to 7 for a local 2.x install, I can't login

I have Craft running locally, the latest 2.x branch. When I change the server to run PHP 7 instead of 5.x, the local Craft frontend still works, but I can't login to the backend. It says "Invalid ...
0
votes
0answers
449 views

ReflectionException since upgrading to PHP 7.2

I've today upgraded from PHP 5.6 to 7.2 so that I could upgrade to Craft 3.0. After needing to install a lot of updates, the craft server check is completely green and says everything should be fine. ...
1
vote
1answer
232 views

Composer Error Updating Craft CMS 3 from RC13 to 14/15

PHP 7.0.28 / MySQL 5.6.38 / Craft Pro 3.0.0-RC13 While trying to update I get this error: Error: An error occurred Output: Loading composer repositories with package information Updating ...
1
vote
1answer
164 views

Include PHP file in plugin

I currently am developing a plugin to gather XML restful data. At one point in the file, I need to reference another PHP file, which will process various data. As a test, the code in the included ...
1
vote
0answers
215 views

How can I filter with facets in algolia with nested structures?

I have a site that currently uses a structure where we have a parent entry and children under it. On the parent page we have entries that have been created with matrix blocks. The structure is as ...
1
vote
1answer
27 views

Using XMLReader With Plugin

In my project, I have a reference to XMLReader in a plugin; however, I get this error message: Class 'Craft\XMLReader' not found Here is the code which calls it: $reader = new XMLReader(); Can ...
1
vote
0answers
57 views

Paginate Results from Restful XML Feed

I'm beginning with Craft/Twig and am developing a plugin that gets data from a Restful XML feed, and I've successfully tested it on my template. Below, I have the working plugin code and a sample of ...
1
vote
2answers
35 views

Widget initialized in Business Logic plugin not loading

Hokay, this is a big one. Thanks in advance for anyone that has a look: I’m trying to get this widget working on a Craft site. The install documentation is pretty simple, I've hosted it here: http://...
1
vote
1answer
107 views

Passing Querystring Variable to PHP Code in Plugin

I'm pretty new to Craft and PHP, and I am needing to design a page in Craft (powered by a plugin) which will pass a variable in a querystring (or equivalent in Craft) to the PHP code in the plugin. In ...
0
votes
0answers
13 views

How to set the URL of a AssetFileModel instance inside a Craft2 Plugin

is there a cleaner solution for this hack? <?php //php 7 $image = new class extends AssetFileModel { /** @var */ public $url; /** * @...
1
vote
1answer
232 views

PHP warning with composer on MacOS High Sierra: Failed to open stream

We have multiple people working on a craft site using Vagrant and Virtual Box for our local server. I am running MacOS Sierra, and everything works as expected. A couple of our other developers have ...
2
votes
1answer
179 views

Craft CMS combining element-api and Simple Map plugin

I've been using element-api for simple lazy-loading of things like blog posts, etc and now want to create a simple 'Postcode lookup' by utilising a custom filter (provided by the Simple Map plugin). ...
1
vote
2answers
463 views

Problem setting security key when installing Craft 3

I'm new to Composer and am using a Mac along with MAMP as a local web server. I've installed Composer but it's referencing an old PHP 5 version that must be the default on my Mac. I was able to ...
2
votes
2answers
661 views

Loop through entries taking far too long to finish

I am attempting to loop through my "journalEntries" in order to find duplicates. For some reason, it is taking a very long time to finish and return a response to me. Last time I tested it, it took 12 ...
0
votes
1answer
56 views

PHP error after adding new field

I've added many fields in the past with success but today, on my local MAMP server, after adding a new field to a Matrix and saving, I'm getting a PHP error when I try to view the entry's admin page, ...
1
vote
2answers
53 views

Homepage showing up as “index of \” page

I am uploading a repo that works fine on a staging server to a live server. When doing so however the homepage is showing as "index of \" page with the public and readme.md directories showing. Like ...
0
votes
0answers
76 views

Class 'HTMLPurifier_Encoder' not found

I'm getting this error after trying to save an entry which contains an invalid character in the slug: Class 'HTMLPurifier_Encoder' not found From there on, it's impossible to access the edit entry ...
1
vote
1answer
809 views

Upgraded to PHP 7.1 - GD or ImageMagick is required

This question relates to two Craft sites running on the same server. One site is a production version, the other is staging. I use WHM v68 and EasyApache 4. Production is on PHP 5.5.38. Staging is on ...
1
vote
2answers
121 views

Craft login problem with memcache and ubuntu?

session_regenerate_id(): Session object destruction failed is the error i'm receiving after attempting to log in. I just updated to Ubuntu 16.04LTS using PHP7 and php-memcached. Is there a fix for ...
1
vote
1answer
453 views

Returning an array to Twig from a plugin

I'am writing a plugin that has to return an array of data, however Twig does not seem to accept it if I return a PHP array. I don't want to use an explode in Twig to make it into an array. I have ...
1
vote
1answer
171 views

renaming a file in onBeforeSaveAsset won't work

I'm trying to rename a file before it is actually saved into Craft, by using the following code snippet in a plugin: craft()->on('assets.onBeforeSaveAsset', function(Event $event) { if($...