一、laravel问题
1.常使用的命令:
(1).artisan常用命令:
php artisan key:generate //设置程序密钥
/*If you have PHP installed locally and you would like to use PHP's built-in development server to serve your application, you may use the serve
Artisan command. This command will start a development server at http://localhost:8000*/
php artisan serve
php artisan serve --port=8080
/*
clear the compiled classes Larvel can optimize class loading and want to clear any optimizations for testing
This deletes two files:
- The
bootstrap/compiled.php
file. This file is created when you optimize classes. - The
app/storage/meta/services.json
file. This file is created as Laravel tries to optimize the loading of the service providers your application uses.*/
php artisan clear-compiled
php artisan optimize //优化应用程序性能,生成自动加载文件,且产生聚合编译文件 bootstrap/compiled.php
(2).composer常用命令:
composer install //install
命令从当前目录读取 composer.json
文件,处理了依赖关系,并把其安装到 vendor
目录下
composer update //为了获取依赖的最新版本,并且升级 composer.lock
文件,你应该使用 update
命令
composer update vendor/package vendor/package2 //如果你只是想更新几个包,你可以像这样分别列出它们
composer update --no-scripts //跳过 composer.json
文件中定义的脚本
/*某些情况下你需要更新 autoloader,例如在你的包中加入了一个新的类。你可以使用 dump-autoload
来完成,而不必执行 install
或 update
命令
此外,它可以打印一个优化过的,符合 PSR-0/4 规范的类的索引,这也是出于对性能的可考虑。在大型的应用中会有许多类文件,而 autoloader 会占用每个请求的很大一部分时间,使用 classmaps 或许在开发时不太方便,但它在保证性能的前提下,仍然可以获得 PSR-0/4 规范带来的便利*/
composer dump-autoload
参考资料:
1.http://docs.phpcomposer.com/03-cli.html
2.遇到的问题:
(1).执行php artisan serve命令时,出现以下错误:
[SymfonyComponentDebugExceptionFatalThrowableError]
Fatal error: Class 'IlluminateFoundationConsoleTestMakeCommand' not found
解决办法:删除vendor目录,执行composer install命令即可