Git Product home page Git Product logo

Comments (6)

mehov avatar mehov commented on August 28, 2024 1

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.

dereuromark avatar dereuromark commented on August 28, 2024 1

If you need examples, you can always check awesome list of plugins:
https://github.com/FriendsOfCake/awesome-cakephp

from docs.

mehov avatar mehov commented on August 28, 2024

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.

LordSimal avatar LordSimal commented on August 28, 2024

"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.

LordSimal avatar LordSimal commented on August 28, 2024

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.

mehov avatar mehov commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.