🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### Composer Composer是PHP中用来管理程序包的工具。(后端库管理工具) 官方网站 https://getcomposer.org/ 浏览全部程序包 https://packagist.org/ 比如 https://packagist.org/packages/yiisoft/yii2-app-advanced ~~~ composer create-project --prefer-dist yiisoft/yii2-app-advanced advanced ~~~ 对照composer.json ~~~ "require": { "php": ">=5.4.0", "yiisoft/yii2": ">=2.0.6", "yiisoft/yii2-bootstrap": "*", "yiisoft/yii2-swiftmailer": "*" }, "require-dev": { "yiisoft/yii2-codeception": "*", "yiisoft/yii2-debug": "*", "yiisoft/yii2-gii": "*", "yiisoft/yii2-faker": "*" } ~~~ ### 安装示例 一个有关DateTime的库 https://packagist.org/packages/nesbot/carbon ~~~ composer require nesbot/carbon # 卸载 composer remove nesbot/carbon ~~~ 安装后注意vendor目录和composer.json文件的变化 frontend\controllers\SiteController.php ~~~ use Carbon\Carbon; public function actionAbout() { $myTime = Carbon::now()->addDay(-2)->toDateTimeString(); return $this->render('about', ['model' => $model, 'myTime' => $myTime]); } ~~~ frontend\views\site\about.php ~~~ /* @var $myTime string */ <p>我的时间:<?= $myTime ?></p> ~~~ ### 框架和库 什么是框架(Framework)? 什么是库(Library)?