Skip to main content
Share Your Experience: Take the 2024 Developer Survey
7 votes
Accepted

Uncaught TypeError Dotenv Create on updating to Craft CMS 4

Looks like your web/index.php file was created for an older version of the vlucas/phpdotenv library. The error method shows that you're initializing the library in a way that's compatible with version ...
MoritzLost's user avatar
  • 11.4k
6 votes
Accepted

Craft 4 upgrade. Entry throwing 'craft\models\EntryDraft doesn’t exist' error in admin

@MoritzLost's answer is partly correct, but this particular error is not due to outdated code in your project. The EntryDraft class was deprecated in Craft 3.2.0, but for some unknown reason (possibly ...
Mats Mikkel Rummelhoff's user avatar
5 votes
Accepted

Craft 4: How to programmatically attach fields to entry type tab

I just ran into this myself. You can use getElements and setElements instead. This is for a category though: use craft\fieldlayoutelements\CustomField; public function safeUp(): bool { ...
twined's user avatar
  • 166
5 votes
Accepted

Questions about Craft 4 release and licenses

1) Is there anything to say about a release date for Craft 4? And about around what time Pixel and Tonic consider it a stable release to be used in production? Nothing official on either. 2) What ...
Brad Bell's user avatar
  • 67.5k
4 votes
Accepted

Craft 4: using the new laravel collections and related methods (in a performant way)

Syntax for Laravel methods using arrow functions in twig ? You're not doing anything wrong, this approach is simply not supported by Twig. Arrow functions in Twig can only be used with built-in ...
MoritzLost's user avatar
  • 11.4k
4 votes
Accepted

Upgrade to Craft 4

To upgrade to Craft 4, you'll need to make sure that Composer is allowed to upgrade all of your plugins to their Craft 4 compatible releases as well. This is done by manually editing your installed ...
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

Contact Form is not working anymore since upgrading from Craft 3 to 4

welcome to the CraftCMS StackExchange 👋 I dug around on the craftcms/contact-form repo and found an open issue for the same error you're describing. Basically, (as things currently stand) you need to ...
Jalen Davenport's user avatar
  • 3,045
4 votes
Accepted

Updating to Craft 4 breaks plugin settings: must not be accessed before initialization

This: class Settings extends Model { public string $apiKey; } Should look like this: class Settings extends Model { public string $apiKey = ''; } What's happening is due to the way Yii2 ...
andrew.welch's user avatar
  • 11.6k
4 votes
Accepted

Feedme Only running Cron jobs when logging in

By default, Craft queue jobs are only run when someone logs into the CP. Your cron job is triggering Feed Me to create the queue jobs, but the jobs themselves won't be run until you log in. There are ...
Martin Spain's user avatar
  • 1,519
4 votes
Accepted

Parent based Selectable Entries Condition

Rendering Twig in the "Selectable Entries Condition" field setting isn't actually possible, but it will be in the upcoming Craft 4.4 release, which as of writing this (march 1st 2023) is due ...
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

PHP version problem when upgrading to Craft CMS 4

The package embed/embed isn't the problem – the newest version supports both PHP 7.4 and 8+. The problem is that you have two plugins that require different versions of that package: newism/craft3-...
MoritzLost's user avatar
  • 11.4k
4 votes

How do I authorize/register visitors on the site?

The free version of Craft does not currently allow for more than a single admin user. You'll need to upgrade to the paid version for this functionality, where everything you mention is possible. Here'...
James Smith's user avatar
  • 5,304
3 votes

Nitro: how risky is it to dev using MariaDB and then go live with MySQL?

My view on this would be it's risky because any environments for a project should ideally all match the same core versions of CMS, PHP version (at minimum same major version) and whatever database ...
James White's user avatar
  • 1,171
3 votes
Accepted

Craft4 stream_copy_to_stream(): Argument #2 ($to) must be of type resource, bool given

I must have looked at the screen for too long. The problem was that I didn't use relative path and url settings. https://craftcms.com/docs/3.x/sites.html#step-6-check-your-asset-volumes-settings Here ...
mcoze's user avatar
  • 41
3 votes
Accepted

Craft 4 Custom Variables - From Env > General.php > template

You're still trying to access the custom config settings through the general config, this is what's causing the error. Instead of craft.app.config.general, use craft.app.config.custom: {{ craft.app....
MoritzLost's user avatar
  • 11.4k
3 votes
Accepted

Log warnings "..before Craft is fully initialized"

This is usually caused by a plugin performing an element query in its init method (see this GitHub issue for more detail). I experienced the same error filling up my log files after upgrading to Craft ...
Martin Spain's user avatar
  • 1,519
3 votes
Accepted

How to check read-only mode in plugin?

The error message you're getting indicates that the allowAdminChanges configuration option is set to false, which means no configuration changes are allowed. This is the default in a production ...
MoritzLost's user avatar
  • 11.4k
3 votes

How to send email from Craft 4 custom plugin/module?

You can do something like this $view = Craft::$app->getView(); $email = '[email protected]' $subject = $view->renderString($messageSubject, $...
aodihis's user avatar
  • 801
3 votes
Accepted

Craft 4 Building a Plugin not saving all properties

Craft automatically sets values from the incoming POST data on your Settings model, which means the input name attributes must match exactly (or that the Settings model must expose an appropriate “...
August Miller's user avatar
3 votes

Craft installation fails with SQL error (PostgreSQL)

Finally I was able to debug and fix the problem. The use of a specific schema in the PosgreSQL DB (instead of public) caused the problem. But not the fact itself was problematic, instead the schema ...
Boris's user avatar
  • 41
3 votes

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

So to clarify what you're seeing with the error message and all the files - this is what is called a stack trace. So the file/code causing the error is always (or at least almost always) the top most ...
Jalen Davenport's user avatar
  • 3,045
3 votes
Accepted

Error when Project.yaml Migration from Local

This looks like a supertable setup, if I'm not mistaken. If you go to the settings menu for the Supertable plugin (assuming you have it installed) there should be some push button tools for fixing/...
cherrykoda's user avatar
  • 1,114
3 votes
Accepted

Run craft up command in deployment pipeline without prompts

You can run most of Craft's console commands using the --interactive=0 flag which will disable interactive prompts for the command. More details in the docs here: https://craftcms.com/docs/4.x/console-...
Steve Rowling's user avatar
3 votes

Craft CMS 4: Update without proc_open

Don't try to work around server limitations on shared hosting, it's rarely worth it. It's just a huge time-sink, and any solutions you find will come with caveats and other problems attached. Craft's ...
MoritzLost's user avatar
  • 11.4k
3 votes

Get list of user logins

Craft only stores the most recent login date for users (i.e. the lastLoginDate). To get a list of all users and their last login date, you could do something like this: {% set users = craft.users.can('...
Mats Mikkel Rummelhoff's user avatar
3 votes
Accepted

Redactor no longer maintained

CKEditor plugin, which is also a first-party plugin by Pixel & Tonic. https://plugins.craftcms.com/ckeditor The Craft 5 version allows for embedding other entries as part of a long form content ...
CraftQuest's user avatar
  • 1,122
2 votes

Questions about Craft 4 release and licenses

Craft 4 will be released in Q1 2022 with a stable release coming in Q2. https://craftquest.io/dotall#state-of-craft
Augustine Calvino's user avatar
2 votes

Craft 4 Custom Variables - From Env > General.php > template

As highlighted by @MoritzLost, in Twig, you should be calling {{ craft.app.config.custom.myVar }}, not using the GeneralConfig service. Also worth highlighting, rather than calling getenv() in your ...
James White's user avatar
  • 1,171
2 votes

Craft 4 doesn't support other languages yet?

Found this solution that worked for me: https://github.com/craftcms/docker/issues/60 docker exec -it --user root YOUR_CONTAINER_NAME sh then with apk add icu-data-full followed by a restart of the ...
jjem's user avatar
  • 497
2 votes

How to programmatically enable Pro trial in Craft 4?

After a bit of noodling around, I figured out it's as simple as: php craft project-config/set system.edition pro Other project-config subcommands may be handy as well, such as: php craft project-...
msbit's user avatar
  • 121

Only top scored, non community-wiki answers of a minimum length are eligible