PHP 辅助库
1.0.0
2017-12-02 03:41 UTC
Requires
- php: >=5.3.3
This package is not auto-updated.
Last update: 2024-09-29 23:31:49 UTC
README
设置
bower install --save creative-workflow.php
or
composer require creative-workflow/php
or
git submodule add https://github.com/creative-workflow/lib-php.git ./wordpress/wp-content/themes/child/lib/cw/php
核心
- Singleton-Trait
- 自动加载器(命名空间或蛇形命名法)
- ArrayAsObject(属性和array_* 方法)
- ObjectAsArray
js
做类似这样的事情
<?
$jQuery = \cw\php\js\jQuery::getInstance();
$jQuery->when(
$jQuery->getScript('...'),
$jQuery->getScript('...'),
$jQuery->getScript('...')
)
->then(
$jQuery->anonymousFunction([],
$jQuery->select('a.fancybox')
->chain('fancybox()')
->chain('animate({opacity: 1})')
->stop()
)
)
->stop();
//output generated js code
echo $jQuery->toJsWrapped();
view/Html
做类似这样的事情
use \cw\php\view\Html;
$html = Html::getInstance()
echo $html->tag('div', ['class' => 'logo-wrapper'])
->append(
$html->image('...', ['class' => 'logo'])
);
echo $html->script(
$jQuery->select('a.fancybox')
->chain('fancybox()')
->chain('animate({opacity: 1})')
->stop()
);
...
view/html/Tag - 标签 - 输入
做类似这样的事情
$labelTag = new Label('zip_code');
$labelTag->addContent('Zip-Code: ');
$inputTag = new Input('zip_code');
$inputTag->typeNumber()
->setId('zip_code')
->setPlaceholder('Your Zip-Code')
->setRequired()
->setAutoCompleteType('postal-code')
->setAndForceMaxLength(5);
return (new Tag())->addClass('row')
->addContent($labelTag)
->addContent($inputTag);