PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, March 17, 2022

[FIXED] I would like to prefix my CakePHP plugins namespace with my name

 March 17, 2022     cakephp, cakephp-3.7, cakephp-3.x     No comments   

Issue

I have a plugin I am calling AdminLTE, and I have other plugins that rely on AdminLTE, so I would like to prefix all my AdminLTE plugins with AdminLTE

For instance

namespace AdminLTE\Calendar\Controller;

Where Calendar is the name of the actual plugin

How would I go about extending the CakePHP Autoloader to be able to find a class like below... And if possible, can I create that autoloader in a plugin?

namespace AdminLTE\Calendar\Controller;

use App\Controller\AppController as BaseController;

class AppController extends BaseController
{
}

Solution

How would I go about extending the CakePHP Autoloader...

Something like this in composer.json:

"autoload": {
    "psr-4": {
        "App\\": "src/",
        "AdminLTE\\Calendar\\": "plugins/Calendar/src/",
        "AdminLTE\\": "plugins/AdminLTE/src/"
    }
}

https://book.cakephp.org/3.0/en/development/configuration.html#additional-class-paths

And if possible, can I create that autoloader in a plugin?

If your plugins have composer.json then it should be possible.



Answered By - bancer
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing