Download the PHP package ozee31/cakephp-override without Composer
On this page you can find all versions of the php package ozee31/cakephp-override. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ozee31/cakephp-override
More information about ozee31/cakephp-override
Files in ozee31/cakephp-override
Package cakephp-override
Short Description Easily override plugin classes and templates for CakePHP
License MIT
Informations about the package cakephp-override
Override plugin for CakePHP
Requirements
- PHP version 5.6 or higher
- CakePhp 3.4 or higher
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
End load plugin in config/bootstrap.php
Configuration
-
Create config file
config/overrides.phpwith this code : -
Add this code in your
config/routes.phpfile and movePlugin::routes()at the end of file - Load Override component in your
AppController
Exemples
Routes
In my example I will override the Croogo plugin but it works with any plugins
If you want rewrite this route :
You must add in config/overrides.php
Templates
Template override is native in Cakephp
If you want rewrite the Users/index.ctp template of MyPlugin, you just need to create the following file in your project : src/Template/Plugin/MyPlugin/Users/index.ctp (src/Template/Plugin/PluginName/ControllerName/ActionName.ctp)
Croogo use subPlugin, If you want rewrite Users/view.ctp template of Croogo.Users plugin, you just need to create the following file in your project : src/Template/Plugin/Croogo/Users/Users/view.ctp (src/Template/Plugin/PluginName/SubpluginName/ControllerName/ActionName.ctp)
Models
Only entity
If you want override the User entity of MyPlugin you must add this code in config/overrides.php
Table and entity
If you want override the User entity and the Users table of MyPlugin you must add this code in config/overrides.php
Only Table
If you want just override the Users table of MyPlugin you must redeclare the entity class :
Helpers
If you want override the TestsHelper of MyPlugin you must add this code in config/overrides.php
Troubleshooting
My model override don't work
Try to clear your cache (tmp/cache/models and tmp/cache/persistent)
When override a route, plugin models are not loaded
You must redeclare models in config/overrides.php
For example