The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [php]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
30 views

How to get current site (locale) api / plugin

For my form plugin I'm using a global set of fields. These can be set in 2 languages default and en. Problem is whenever I try to output them I cant dynamically make them use the current site locale/...
1
vote
1answer
26 views

Custom module controller getView()->renderTemplate() path not working

Module loads and controller actions work. Craft 3.3.7. I'm trying to find out what is the path to use to render the view. From the Doc: return $this->renderTemplate('plugin-handle/path/to/...
0
votes
0answers
59 views

Craft can’t connect to the database with the credentials in craft/config/db.php

I'm trying to upgrade from 2.7.10 to Craft 3. I follow the instructions/ docs to the letter, go to https://###.com/admin and am greeted with the above can't connect to database message. So far, I ...
0
votes
0answers
17 views

Undefined property: DOMElement::$tagName HTMLPurifier

I got asked to edit the content on a website but whenever I edit an article and try to save it I get the following error: Undefined property: DOMElement::$tagName (/home/user/craft/app/framework/...
1
vote
0answers
40 views

Craft Commerce Adjuster API/PHP questions

I've got a module set up to add discounts based on criteria defined in a category group (handle 'productPacks') -> category (which is a "pack"). Now, everything works great for one type of pack, and ...
1
vote
1answer
19 views

Local DB SQL 'CDbException' Errors on Craft 2 site

Just tried to get a local site working again but getting all sorts of issues. I have updated the website online and downloaded the database, installed locally. I have also the craft/app folder to my ...
1
vote
2answers
22 views

Laravel Forge not honoring Craft 3 maxUploadFileSize config setting

I have a Craft 3 site deployed to a Digital Ocean droplet via Laravel Forge. I have the maxUploadFileSize set to 256B (268435456 in bytes) in my config/general.php like so: <?php return [ // ...
3
votes
2answers
122 views

How to access HTML input values from Twig and vice versa

I am new to Craft and Twig in general. I have encountered the following problems and struggling to find a solution for hours. I want to access the value of "foo" input field inside the twig ...
0
votes
0answers
22 views

Update asset index by PHP in Craft 3

In my plugin, I need to update asset indexes because it makes new asset folders. I found this question, but the answer is for Craft 2. How do you programmatically update an asset index? It does not ...
1
vote
1answer
39 views

PHP Login & Sessions without Craft Commerce?

I'm trying to implement this tutorial in my Craft CMS site, I've created all the files and they currently reside in public_html, but twig and the .htaccess of Craft CMS is interfering with it. Does ...
0
votes
0answers
111 views

MacOS 10.15 Beta and CraftCMS

i'm running a macOS 10.15 Beta (to check out SwiftUI) but now i'm running into problems with craft, specifically with the php zip extension. It's PHP 7.3.5 and i can't update it, because the install ...
1
vote
1answer
40 views

User query in PHP does not work

I would like to get user query in my custom PHP plugin. According to this document, the code would be like this. https://docs.craftcms.com/v3/dev/element-queries/user-queries.html#example $...
1
vote
1answer
36 views

Get radio button's value from a form by PHP

I have been developing validations for my form. It is possible to get text input's value like; $password = Craft::$app->request->getBodyParam('password'); However, this function seems not to ...
1
vote
2answers
42 views

Prevent EVENT_BEFORE_VALIDATE in specific case

I have a registration form and its custom validation in PHP plugin code. However, the validation works when user set a new password. I supposed that $event->isNew is good to detect if it is a new ...
1
vote
1answer
14 views

Detect if it is a new user or not in PHP

I have been developing some plugin code for my registration form in Craft 3. The event will be EVENT_AFTER_SAVE_ELEMENT, but I do not know how to detect if it is a new user or not. In Craft 2, the ...
1
vote
2answers
81 views

Rename Assets when it is uploaded

I would like to rename new assets by PHP, but somehow it does not work. In Craft 3, I suppose it is like; Event::on(\craft\services\Elements::class, \craft\services\Elements::EVENT_AFTER_SAVE_ELEMENT,...
0
votes
1answer
30 views

Fatal PHP error upon installation

I attempted to install the newest version of Craft and received this error in my logs: PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\craft-cms\vendor\yiisoft\yii2\...
1
vote
1answer
116 views

PHP Fatal error during installation

I am trying to run craft inside a homestead box. The box boots and installs everything correctly, and when I navigate to http://localhost:8000/admin I see the install screen and can click through the ...
2
votes
1answer
33 views

Create Matrix Block via Module

I'm having an issue creating a matrix block from a module. I'm currently doing the following: Calling an API using Guzzle Getting that request and iterating over a media block. Trying to create a new ...
0
votes
0answers
37 views

Craft CMS: Goes Unresponsive

I have an issue with the Craft3, after a few requests and clicking around the whole site (front-end and CP Admin) seems to hand and lag. Also I get a popup message on Google Chrome mentioning that ...
0
votes
0answers
25 views

Install of Craft 3 on Windows server gets 404 error on admin pages

I have tried installing Craft 3 onto a Windows 2016 server a few times and I've gotten the same issue where after an install I am redirected to the Admin page and have a 404 server error. I am using ...
0
votes
1answer
50 views

Call Module Function from Front End

I'm looking to call the following Module function from a front end form. I've looked through numerous answers but I can't seem to find a definitive answer on this. Here's my Module's code, but ...
0
votes
0answers
16 views

Injecting filename into all templates?

I found a topic about getting the current filename for templates here: How can I make a template output its own filename? but I am curious, is there some way I can get the server to implement this ...
1
vote
2answers
122 views

Simple Module in Craft CMS 3

How do I create a simple module for one website in Craft?. I don't have much experience in Craft CMS. I have tried from 3 days but I cannot get an answer. I'm following all the tutorials that I can ...
0
votes
0answers
18 views

Print to Console Inside Event

I created a CUSTOM PLUGIN and I have the following code: Event::on(FOO::class, FOO::EVENT_NAMED_BAR, function(Event $e) { $message = "Hello world"; // craft::error( $message ); // ...
0
votes
0answers
45 views

Emojis on Craft 3 front office

I'm making a blog. I have a wheelform comments input type that needs to be stored as utf8mb4 in the local database. My MySQL database version 5.6 is configured to utf8mb4 in the database, tables, ...
3
votes
1answer
177 views

How do I prevent secrets beeing logged in the PHP error log?

Background: I'm running Craft Pro 3.1.19 on PHP 7.2.15 Craft CMS, by default, uses vlucas/phpdotenv to get the configuration (containing secrets / credentials and lots of other stuff) from .env ...
1
vote
1answer
68 views

Custom title using URI segment

I am working on my SEO and I am getting a duplicate title in Craft. I want to make a custom title using the URI segment in using PHP.
1
vote
1answer
237 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
vote
1answer
24 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 ...
3
votes
1answer
110 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
205 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
95 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
99 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
57 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
2answers
58 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
157 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 ...
2
votes
1answer
107 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 ...
2
votes
1answer
529 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....
2
votes
0answers
309 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
86 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
185 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
298 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 ...
3
votes
1answer
127 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
196 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
49 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
165 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
2answers
551 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(...
4
votes
1answer
190 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
82 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][-...