|
|
7 years ago | |
|---|---|---|
| Config | 10 years ago | |
| Console | 9 years ago | |
| Controller | 7 years ago | |
| Lib | 8 years ago | |
| Locale | 11 years ago | |
| Model | 8 years ago | |
| Test | 9 years ago | |
| TestSuite | 11 years ago | |
| Vendor | 9 years ago | |
| View | 7 years ago | |
| docs | 10 years ago | |
| webroot | 14 years ago | |
| .editorconfig | 10 years ago | |
| .gitattributes | 11 years ago | |
| .gitignore | 9 years ago | |
| .travis.yml | 9 years ago | |
| CONTRIBUTING.md | 11 years ago | |
| LICENSE | 9 years ago | |
| README.md | 8 years ago | |
| composer.json | 8 years ago | |
| phpunit.xml | 10 years ago |
A CakePHP 2.x Plugin containing several useful tools that can be used in many projects. This plugin requires PHP5.4+ (use the old 2.5 branch if you need PHP5.3 until you can upgrade).
Please note: New functionality has been tested against 2.x (current master branch) only. Please upgrade your app to latest CakePHP 2.x if possible. Use a different 2.x branch if you need temporary support for older versions.
EOL: This 2.x branch is EOL and only gets bugfixes now. Please upgrade to 3.x to get the latest features.
Installing the Plugin is pretty much as with every other CakePHP Plugin.
APP/Plugin/Tools.CakePlugin::load('Tools') or CakePlugin::loadAll() in your bootstrap.You should use composer/packagist now @ https://packagist.org/packages/dereuromark/cakephp-tools
"require": {
"dereuromark/cakephp-tools": "2.x-dev"
}
That's it. It should be up and running.
In case you want the Tools bootstrap file included (recommended), you can do that in your APP/Config/bootstrap.php with
CakePlugin::load('Tools', ['bootstrap' => true]);
For CakePlugin::loadAll() it's
CakePlugin::loadAll([
'Tools' => ['bootstrap' => true]
]);
MyModel can be extended to use more powerful validation and other improvements:
App::uses('MyModel', 'Tools.Model');
class AppModel extends MyModel {
}
MyController can be extended for DRY improvements and to fix some common bugs:
App::uses('MyController', 'Tools.Controller');
class AppController extends MyController {
}
MyHelper can be extended and used this way:
App::uses('MyHelper', 'Tools.View/Helper');
class AppHelper extends MyHelper {
}
The test suite improvements can be used via:
App::uses('MyCakeTestCase', 'Tools.TestSuite');
class SomeClassTest extends MyCakeTestCase {
}
To run any of the console commands (replace [ShellName] and [command]!):
cake Tools.[ShellName] [command]
The models, behaviors, helpers, libs and other classes are used the same way prefixing them with the plugin name:
App::uses('GooglLib', 'Tools.Lib');
App::uses('TimeLib', 'Tools.Utility');
App::uses('GeocoderBehavior', 'Tools.Model/Behavior');
...
Tip: For how to use them, try to find some information in the test cases. For a quick reference or some larger modules see the Tools Plugin Wiki
For including components, helper and behaviors you don't need App::uses() calls. So for a pretty standard CakePHP app with some Tools plugin enhancements, the AppController could look like this:
public $components = [
'Session', 'RequestHandler', 'Tools.Common', 'Auth'
];
public $helpers = [
'Session', 'Html', 'Form' => ['className' => 'Tools.FormExt'],
'Tools.Common', 'Tools.Format', 'Tools.Datetime', 'Tools.Numeric'
];
echo $this->Flash->message(); then instead of the default flash code in your layout.ctp template.
And bear in mind that it will eat all your normal flash messages and outputs it though the same method.A full list of fixes and useful migration tweaks towards the next major version see here.
Also see the Shim plugin for details and documentation on more possible shims you can leverage.
Use at your own risk. Please provide any fixes or enhancements via issue or better pull request. Some classes are still from 1.2 (and are merely upgraded to 2.x) and might still need some serious refactoring. If you are able to help on that one, that would be awesome.
nuluke in IRC:
"I've been using Tiny(Auth) for a year now, it's dead simple amazing. tiny + tools plugin saved me tons of time."
[Yours here? Contact me]
The master branch is the currently active and maintained one and works with the current 2.x stable version. Older versions might be found in their respective branches (2.0, 2.4, ...). Please provide PRs mainly against master branch then.
For details on how to contribute please read the CONTRIBUTING page.