|
|
11 年之前 | |
|---|---|---|
| Config | 11 年之前 | |
| Console | 11 年之前 | |
| Controller | 11 年之前 | |
| Lib | 11 年之前 | |
| Locale | 11 年之前 | |
| Model | 11 年之前 | |
| Test | 11 年之前 | |
| TestSuite | 11 年之前 | |
| Vendor | 11 年之前 | |
| View | 11 年之前 | |
| webroot | 14 年之前 | |
| .travis.yml | 11 年之前 | |
| CONTRIBUTING.md | 12 年之前 | |
| README.md | 11 年之前 | |
| composer.json | 11 年之前 | |
| phpunit.xml | 11 年之前 |
A CakePHP 2.x Plugin containing several useful tools that can be used in many projects. This plugin requires PHP5.3+
Please note: New functionality has been tested against 2.x (current master and dev) only. Please upgrade if possible.
Installing the Plugin is pretty much as with every other CakePHP Plugin.
APP/Plugin/ToolsCakePlugin::load('Tools') or CakePlugin::loadAll() in your bootstrapTip: You can also use packagist now @ https://packagist.org/packages/dereuromark/cakephp-tools
"require": {
"dereuromark/cakephp-tools": "dev-master"
}
or use the tags, e.g. 0.4 directly.
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', array('bootstrap' => true));
For CakePlugin::loadAll() it's
CakePlugin::loadAll(array(
'Tools' => array('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 MyController 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 = array(
'Session', 'RequestHandler', 'Tools.Common', 'Auth');
public $helpers = array(
'Session', 'Html', 'Form' => array('className' => 'Tools.FormExt'),
'Tools.Common', 'Tools.Format', 'Tools.Datetime', 'Tools.Numeric');
A full list of fixes and useful migration tweaks towards the next major version see here.
and much more
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.
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 (1.3, 2.0, 2.3, ...). Please provide PRs mainly against master branch then.
For details on how to contribute please read the CONTRIBUTING page.
Licensed under The MIT License unless specified otherwise (in the classes).