cakephp / docs

CakePHP CookBook
http://book.cakephp.org
Other
680 stars 2.58k forks source link

Plugin naming: lowercase or camelcase? #7568

Closed mehov closed 1 year ago

mehov commented 1 year ago

https://book.cakephp.org/4/en/intro/conventions.html#plugins-conventions:

The convention is to use lowercase letters and dashes as separator

your-name/cakephp-foo-bar

https://book.cakephp.org/4/en/plugins.html#manually-autoloading-plugin-classes:

"MyPlugin\\": "plugins/MyPlugin/src/"

I'm working on a plugin now, referred to the docs and got confused.

It's also unclear if for a plugin named cakephp-example the namespace would be CakePHPExample or CakephpExample.

mehov commented 1 year ago

Still investigating.

When I went to example.com/cakephp-wordpress, I got a plain white page that says An Internal Server Error Occurred. This is not a red CakePHP error page, doesn't have the Debug Kit on it - just a plain white error page.

Here are the entries from logs/error.log:

Request URL: /cakephp-wordpress/ error: [Cake\Http\Exception\MissingControllerException] Controller class Posts could not be found. in /var/www/app/vendor/cakephp/cakephp/src/Controller/ControllerFactory.php on line 348 Exception Attributes: array ( 'class' => 'Posts', 'plugin' => 'CakephpWordpress', 'prefix' => NULL, '_ext' => NULL, )

Request URL: /cakephp-wordpress/ error: [Cake\Core\Exception\MissingPluginException] Plugin CakephpWordpress could not be found. in /var/www/app/vendor/cakephp/cakephp/src/Core/PluginCollection.php on line 143 Exception Attributes: array ( 'plugin' => 'CakephpWordpress', )

So apparently, it takes the plugin name from within the route. And because the route is cakephp-wordpress, it looks for the plugin CakephpWordpress. But the plugin is still cakephp-wordpress.

However, everything works as soon as I:

mehov commented 1 year ago

It's the namespace that makes the difference. It has to be CakephpWordpress. With that namespace, the lowercase folder name works too.