环境:mac os 10.10.5; php 5.6.9;
文档参考: http://www.golaravel.com/
包管理: python 一般使用 pip
Laravel 利用 Composer(Composer 中文)来管理其自身的依赖包。
安装:
代码语言:javascript复制lpe234@lpe234demacbookpro:/Users/lpe234 $ brew tap josegonzalez/homebrew-php
Warning: Already tapped!
lpe234@lpe234demacbookpro:/Users/lpe234 $ brew install josegonzalez/php/composer
==> Installing composer from josegonzalez/homebrew-php
==> Downloading http://getcomposer.org/download/1.0.0-alpha10/composer.phar
######################################################################## 100.0%
==> Caveats
Verify your installation by running:
"composer --version".
You can read more about composer and packagist by running:
"brew home composer".
==> Summary
? /usr/local/Cellar/composer/1.0.0-alpha10: 3 files, 1.0M, built in 58 seconds
lpe234@lpe234demacbookpro:/Users/lpe234 $ composer --version
Composer version 1.0.0-alpha10 2015-04-14 21:18:51
Laravel 框架安装
代码语言:javascript复制lpe234@lpe234demacbookpro:/Users/lpe234 $ composer global require "laravel/installer=~1.1"
Changed current directory to /Users/lpe234/.composer
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing symfony/process (v2.7.6)
Downloading: 100%
- Installing symfony/console (v2.7.6)
Downloading: 100%
- Installing guzzlehttp/promises (1.0.3)
Downloading: 100%
- Installing psr/http-message (1.0)
Downloading: 100%
- Installing guzzlehttp/psr7 (1.2.1)
Downloading: 100%
- Installing guzzlehttp/guzzle (6.1.0)
Downloading: 100%
- Installing laravel/installer (v1.2.2)
Downloading: 100%
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing psr/log (For using the console logger)
Writing lock file
Generating autoload files
安装完成之后,配置环境变量。
代码语言:javascript复制export PATH=$PATH:~/.composer/vendor/bin
然后验证是否成功。重启terminal
代码语言:javascript复制lpe234@lpe234demacbookpro:/Users/lpe234 $ laravel --version
Laravel Installer version 1.2.2
创建一个项目
代码语言:javascript复制lpe234@lpe234demacbookpro:/Users/lpe234/PhpstormProjects $ laravel new blog
Crafting application...
Generating optimized class loader
Application key [NhGlYwNWoJkRSW4ElhLghXy2FtAlZmBI] set successfully.
Application ready! Build something amazing.
异常:
RuntimeExceptionin EncryptionServiceProvider.php line 29:
No supported encrypter found. The cipher and / or key length are invalid.
代码语言:javascript复制php artisan key:generate
然后将 生成的 32位key. 放到 config/app.php 下面的 APP_KEY ; 以及 .env 中的 APP_KEY
之后 php artisan serve 错误依旧~~~~~~~
问题已解决:
原因是 未使用 sudo php artisan serve 导致无权限读取文件,无法获取APP_KEY
另外推荐不错的视频教程: https://laravist.com
补充: 还有一个可能的原因是 在系统环境中已设置 APP_KEY 这个优先级貌似高于 .env 文件中的设置