CrossPHP1.5.5 released, lightweight PHP development framework ~ 1.5.5 update description 1. enhanced annotation configuration
-
@ Cp_params all types of url styles take effect
-
Enhanced @ cp_cache. you can inject anonymous function containers into the entry file to change the behavior.
$app = Cross\Delegate::loadApp('web');$app->on('cpCache', function(&$cache_config) { $cache_config['key'] = 'abc'; return true;});$app->run(); In this case, the return value of the anonymous function is used as the switch to determine whether the request cache is effective.
-
@ Cp_before, @ cp_after supports direct use of $ self-> method name () to call the internal method of the controller.
II. basic methods for enhancing the View Controller
Add the following methods to the view controller and template to process HTML tags:
-
The a () method is used to generate a hyperlink.
-
The img () method is used to generate an image connection.
-
Input () processing form input box
-
Radio (), checkbox (), select processing ticket/check/drop-down
-
HtmlTag () outputs separate html tags
-
Wrap () is used to generate complex html
$this->wrap('p') ->wrap('span') ->a('crossphp', 'http://www.crossphp.com'); The generated html code is
crossphp
For more usage instructions, see the document or discuss it in the official group.
-
Block () outputs block-level elements with wrap ()
-
BuildForm (form template name): when the template is loaded as a form, you can register an anonymous function buildForm at the entry to change the form generation behavior of the framework.
$this->on('buildForm', function(){ .... });
-
Html () is used to safely output html content.
Layout problems
Section (template name, template data, array package attributes, package name) in the view controller and template, rendering different templates according to different logic.
III. Other optimizations
-
Standardized variable naming
-
If you call the to () method in the controller, the execution will be terminated. you do not need to add return to the controller.
-
Determine whether the controller and parameters are empty before generating a connection.
-
Updated document