Skip to main content
10 votes
Accepted

Yii2 not maintained?

It’s still maintained. 2.0.48 is currently in development, and 2.2 is being planned as well. That said, the core maintainers’ focus has shifted to Yii 3, which is a drastic departure from Yii 2, and ...
Brandon Kelly's user avatar
9 votes
Accepted

Craft 3: how to show the Yii Debug Toolbar?

There are two checkboxes in your user settings, go to your admin account -> preferences index.php?p=admin/myaccount and check the boxes This is covered in detail in the Profiling your Website with ...
Robin Schambach's user avatar
5 votes

Craft 3: how to show the Yii Debug Toolbar?

For anyone finding it annoying having to be authenticated to enable the debug bar, particularly when testing in multiple browsers, it’s easy to override this behaviour with a custom module. Just add ...
Dom Stubbs's user avatar
5 votes

Craft 3: how to show the Yii Debug Toolbar?

Craft 3 If you enabled the debug toolbar in the user profile, but it still does not show on the frontend, AND you are running Craft not locally but on a different host (different IP), try adding this ...
Udo's user avatar
  • 607
5 votes
Accepted

How to access HTML input values from Twig and vice versa

You can do it without JavaScript (if you don't mind the page refreshing) by accessing the request variable: https://docs.craftcms.com/api/v3/craft-web-twig-variables-request.html#public-methods {{ ...
missmatsuko's user avatar
4 votes

Craft CMS V3 Create New User

Take a look at Craft's own UsersController->actionSaveUser(). You're probably looking for something closer to this: $user = new craft\elements\User(); $user->firstName = $firstName; $user->...
Brad Bell's user avatar
  • 67.5k
4 votes
Accepted

PHP Fatal error during installation

See this issue: https://github.com/craftcms/cms/issues/4355#issuecomment-498829513 reproduced here for completeness: A yii variable 'isWindows' is apparently the way to correct this issue, but I ...
Ethan Davidson's user avatar
3 votes

Craft 3 404 and 503 pages in devMode

Just posting this here since I saw an official answer in Github: This changed in Beta 7: UserException reports are now styled like other exceptions when Dev Mode is enabled, with the full ...
Alex Kendrick's user avatar
3 votes
Accepted

Joining two plugin tables by reference Id causes duplicates

You're probably looking for an inner join (which Yii just calls a join)instead of a leftJoin: https://blog.codinghorror.com/a-visual-explanation-of-sql-joins/
Brad Bell's user avatar
  • 67.5k
3 votes

How to access HTML input values from Twig and vice versa

Twig (at least within the context of Craft) doesn't work this way I'm afraid. The Twig template is processed on the server and HTML is returned to the browser. You're trying to change the Twig based ...
foamcow's user avatar
  • 2,029
3 votes
Accepted

Combine AND and OR in a ElementQuery

If I understand properly, you should be able to do this: $entries = \craft\elements\Entry::find() ->section('yourSection') ->category(['and', 695]) ->relatedTo([698,698])->all()...
Oli's user avatar
  • 7,495
3 votes
Accepted

Debugging with dump()/dd() within Twig templates

This bothered me too until I switched to PHPStorm and started using this: https://github.com/nystudio107/craft-autocomplete. If that's not an option and you fancy extending Twig, you can use php's ...
James Smith's user avatar
  • 5,344
2 votes
Accepted

Craft equivalent to Rails runner

Maybe you're just looking for a bootstrapped Craft instance? Something like: $craft = require '/path/to/craft/app/bootstrap.php'; From there you'll have access to the Craft instance as usual: $...
Brad Bell's user avatar
  • 67.5k
2 votes
Accepted

Yii Modules in Craft, samples?

In the context of Craft CMS, Modules typically would be used for adding functionality to the website itself. As such, you'd use it for things that are specific to that project. Check out the article ...
andrew.welch's user avatar
  • 11.6k
2 votes

400 error logging into local Craft 3 project

I haven't seen this particular issue but generally I've found that from time to time MAMP doesn't like running Craft in CGI mode, i.e. with different PHP versions per host. Try switching it to module ...
foamcow's user avatar
  • 2,029
2 votes

400 error logging into local Craft 3 project

I just had this issue and I found that I caused it by setting the defaultCookieDomain to something else, than where my Craft website was running. The effect was that the CSRF cookie was never sent to ...
Jan Klan's user avatar
  • 215
2 votes

Craft Rules and Validation

I just figured out the answer so I'm going to post it if anyone else is asking this question. Yii accepts aliases as well as function/class names when evaluating the rules function. When using number ...
Mat Weaver's user avatar
2 votes

CraftCMS 3 - Composer Update

You can't. The composer.json file (and the composer.lock file so you can't even reverse engineer composer.json) isn't shipped with the official release on purpose. Craft 3 is still in development ...
Brad Bell's user avatar
  • 67.5k
2 votes
Accepted

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

The correct path would be return Craft::$app->getView()->renderTemplate('subscribing-module/templates/default',['mypost' => $request]); And the file lives in modules/subscribingmodule/src/...
Christopher Dosin's user avatar
2 votes

Pass params to transform function of Transformer class in split Transformer class

Here's how you would do that... Pass your parameter to the class: 'transformer' => new MyTransformerClassName($user), Use a constructor to save it as a property: class MyTransformerClassName ...
Jalen Davenport's user avatar
  • 3,045
2 votes

Nesting level too deep - recursive dependency?

I figured this out, with help from a GitHub thread or too. It appeared that using the sort filter on an array of objects was problematic. I was able to fix this by sorting the keys in speakers instead ...
Jake Dohm's user avatar
  • 766
2 votes

Twig json_decode gives Syntax Error

After some local experimentation I managed to reproduce and (hopefully) resolve. Like Brad said the macro returns a Markup class that is not json decodable. So first step is to use the raw filter to ...
Matanya's user avatar
  • 472
2 votes

Not instantiable – yii\di\NotInstantiableException when setting and reading cookies

So your code should actually be: {% set cookie = create({ class: 'yii\\web\\Cookie', name: 'letzterBesuch', value: now | atom, }) %} Notice the ...
andrew.welch's user avatar
  • 11.6k
2 votes

evaluateDynamicContent() is disallowed

As the debug toolbar is build-in, you do not have to add it with composer. You can enable the build-in debug toolbar in the upper right corner on your control panel. Click on your user account Tab: ...
user3086053's user avatar
1 vote

CraftCMS config on WTServer / WinNMP for Windows with Nginx

This is my clean wtserver/winnmp nginx conf file for Craft (and pretty much anything else like Laravel etc.). server { listen 127.0.0.1:80; server_name icraft.test; # locked ...
Jure Srpcic's user avatar
1 vote
Accepted

upgrade issue Yii Framework from version 2.0.15.1 to 2.0.16.1

Not sure about the Yii message, though it may be irrelevant. The Twig message refers to an issue where Twig itself was upgraded (to 2.7.2) which broke Craft. The makers of Craft were able to publish ...
Lindsey D's user avatar
  • 24k
1 vote

How do I prevent a controller from creating unwanted routes?

I think you're "fighting the system" for no great gain, but anyway I think this is what you want: /** * @var bool|string[] Whether this controller’s actions can be accessed anonymously *...
andrew.welch's user avatar
  • 11.6k
1 vote
Accepted

How do I prevent a controller from creating unwanted routes?

After too much time spent on this, I think I found a solution to both issues. 1) To prevent controller actions meant for the CP from being accessible on the front-end (via actions/<module>/<...
benface's user avatar
  • 226
1 vote
Accepted

Integrating Yii 2 modules and frontend widgets with Craft CMS 3

If you go down the route of creating your own modules for craft/yii2: You can register access from twig to PHP services in your modules init() function Event::on(CraftVariable::class, CraftVariable::...
Sam's user avatar
  • 308
1 vote
Accepted

How do I create console commands for my module or plugin?

What's the equivalent for registering console commands? You don't need to listen to an event to create a console command. Assuming your namespacing and autoloading is set up correctly, they'll "just ...
Brad Bell's user avatar
  • 67.5k

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