Comments (6)
Hi @LordSimal, thank you for replying
You have to specify in your root composer.json
Yes, I did put the namespace I wanted into the root (not plugin) composer.json file and I did run composer dump-autoload
afterwards, as well as bin/cake cache clear_all
just to be sure.
At least you didn't mention it.
You're right, I just never mentioned it - sorry about that. I do have it and once I used the namespace CakePHP wanted (the camelcase version of the plugin folder name) everything routed correctly and I got my test response from that Posts controller.
from docs.
If you need examples, you can always check awesome list of plugins:
https://github.com/FriendsOfCake/awesome-cakephp
from docs.
Tried putting the namespace I want into composer.json
, and using it across the plugin files (#7568) - doesn't work with routing, as the system is still looking for the namespace derived from plugin name/path.
from docs.
"Private" plugins live in the plugins
directory and are NOT autoloaded by composer
"Usual" plugins installed via e.g. composer require cakephp/debug_kit
live in the vendor
directory ARE autloaded.
You have to specify in your root composer.json (NOT the plugins composer.json) which namespace maps to which folder relative to that composer.json
see https://book.cakephp.org/4/en/plugins.html#manually-autoloading-plugin-classes
Just like you did in #7568 you have to define
"CakePress\\": "plugins/cakephp-wordpress/src"
in your root composer.json and regenerate the autoloader via composer dump-autoload
to let composer know where your namespace lives. With that at least PHP knows which file it has to load if you reference a class in the namespace CakePress
The other problem you have in #7568 is probably related to the fact, that you don't have a PostsController
inside your plugins/cakephp-wordpress/src/Controller
directory. At least you didn't mention it.
from docs.
If you feel like the docs can be improved you can of course provide a PR which clarifies what confused you in the first place.
Regarding any future support questions I can recommend you join our slack/discord server or our discourse forum.
See https://cakephp.org/get-involved#getHelp
from docs.
Sending a PR implies knowing the solution, but I don't have any. I have tried several things, but I couldn't get my plugin to use the custom namespace I wanted and have functioning routes. I am already on the Slack channel, but that is indeed for one-off support questions, while here on Github I am asking someone who has the answer to improve the docs.
from docs.
Related Issues (20)
- Router Class HOT 1
- Options for Route Prefixes not well documented HOT 2
- AuthenticationMiddleware recommended position HOT 1
- 5.x: Type::build() removal missing HOT 5
- Plugin naming: lowercase or camelcase? HOT 2
- "Using Validation as Application Rules" does not work with IsUnique rule HOT 11
- Query doc split or not. HOT 3
- 5x: Security and Csrf components missing - docs HOT 1
- CMS Tutorial:Authentication - Hint on checking the config for session.cookie_secure ? HOT 2
- A
- \Cake\Database\Connection::connect() not mentioned in 5.0 migration guide HOT 2
- \Cake\Filesystem\Folder::copy() does not match documentation
- Some links in footer are broken HOT 2
- OpenSearch Feature Broken for most CakePHP Versions HOT 2
- 5.x Review and update examples HOT 2
- 5.x Review method signatures HOT 3
- Clarify `recursive()` usage for CTE HOT 1
- Remove "blog" tutorial from 5.x docs, enhance the CMS tutorial HOT 3
- Missing Controller::setAction HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.