asper / replacer
CakePHP output string replacement
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:cakephp-plugin
This package is not auto-updated.
Last update: 2025-02-25 03:53:01 UTC
README
Provides a simple graphical interface to replace strings in CakePHP's output using regular expressions.
Possible usages :
- Format text (ex : m2 => m², mysql => MySQL, cAkePHp => CakePHP...)
- Add code to every page (</body> => <script>analytics();</script></body>)
- Add a CDN to remote assets (src="js/script.js" => src="http://cdn.example.com/js/script.js")...
- ...
Setup
-
Clone repository :
$ cd /my/app/root && git clone git://github.com/asper/Replacer.git Plugin/Replacer
-
Load plugin in
app/Config/bootstrap.php
:CakePlugin::load(array( 'Replacer' => array( 'routes' => true ) ));
-
Create schema :
$ cd /my/app/root && cake schema create Replacer.replacer
-
Open
app/webroot/index.php
and search for (l. 96 for CakePHP 2.1) :$Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));
-
Replace this line with :
App::import('Lib', 'Replacer.ReplacerResponse'); $Dispatcher->dispatch(new CakeRequest(), new ReplacerResponse(array('charset' => Configure::read('App.encoding'))));
-
Enable
admin
routing prefix by uncommentingConfigure::write('Routing.prefixes', array('admin'));
inapp/Config/core.php
-
Navigate to
http://my-app/admin/replacer
and start configuring the plugin
Usage
Replacer Plugin is composed of 2 main sections Replacements
and Scopes
Replacements
let you substitute strings in output using regular expressions
Scopes
let you choose where these substitutions should occur