1. Go to this page and download the library: Download ozee31/cakephp-override library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ozee31 / cakephp-override example snippets
Plugin::load('Override', ['bootstrap' => true]);
return ['Overrides' => [
'routes' => [
/*
* (!) You must also add the model override
*/
],
'models' => [
/*
* (!) Always redeclare entityClass when overriding className otherwise cakephp does not use it
*/
],
'helpers' => []
]];
// Use Override class
use Override\Routing\Override;
Router::scope('/', function (RouteBuilder $routes) {
// In Router scope add this code
Override::connect($routes);
// ... other routes
});
// Plugin routes must be declared after Override::connect()
Plugin::routes();
public function initialize()
{
parent::initialize();
$this->loadComponent('Override.Override');
}
'helpers' => [
'MyPlugin.Tests' => [
'className' => 'Tests', // must be the same name of original
'controllers' => true, // true if you want override for all Controllers, an array or a string otherwise
]
]