laravel框架安装
传送门: goofyy技术宅
Laravel-简洁、优雅的PHP开发框架(PHP Web Framework)
PHP是一门优秀的语言,当php遇上Laravel框架,简直了,Laravel框架是PHP框架排行榜最高的框架,小编暑假闲来没事也是玩一玩。不多扯,首先是Laravel框架的安装,很多新手死在了这一步。
首先写一下小编的开发环境:
安装环境:
操作系统:Mac OS X10.10.4
数据库:mysql 5.5.16
PHP: 5.5.24
小编使用的是Laravel5.1。PHP版本要求是 >=5.5.9 Mysql 5.1+
OpenSSL PHP 扩展 - PDO PHP 扩展 - Mbstring PHP 扩展 - Tokenizer PHP 扩展
安装Laravel
Laravel的安装有三种方式。
composer安装
Composer是PHP中用来管理依赖(dependency)关系的工具。你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer会帮你安装这些依赖的库文件。
在要安装的路径下执行:
composer create-project laravel/laravel learnlaravel5
下面就是将网站的根目录配置为learnlaravel5/public
php -S localhost:8000 -t public
goofy-2:blog goofygao$ php -S localhost:8000 -t publicPHP 5.5.24 Development Server started at Thu Jul 30 16:58:16 2015Listening on http://localhost:8000Document root is /Users/goofygao/laravel/blog/publicPress Ctrl-C to quit.
同样根目录下的artisan工具也是可以开启服务的。根目录执行
php artisan serve 同样开启服务
然后此时在浏览器里访问http://localhost:8000 配置成功,访问如下图
通过Laravel安装器
通过composer安装器下载Laravel安装器
composer global require "laravel/installer=~1.1"
laravel new blog
执行完成之后,会生成一个blog的目录。安装成功。同样要注意权限,其他同上。
源码安装
首先要从github或者Laraverl官网下载Laravel源码包,解压后,安装。
下载地址:http://www.golaravel.com/download/
我们看一下解压后的一个文件composer.json。这个文件主要是composer下载Laravel的依赖和配置信息。
如果想添加对应的配置信息,可以去 https://packagist.org/ 这个网站下载配置。
例如小编想添加邮件mail的配置信息。只需要搜索mail。选择对应版本。在composer.json添加如图所示配置信息即可
require nette/mail
在composer.json添加即可。
然后在根目录执行
php composer.phar install
composer install
php composer.phar update
安装完成后,按照如上的配置既可以访问。
下面就是做一些简单地配置。更改一下Key配置。
安装 Laravel 之后接下来需要做的就是设置一个随机字串作为应用的秘钥(key)。如果你是通过 Composer 或 Laravel 安装器安装的 Laravel,这个 key 已经由 key:generate 命令自动生成并设置了。一般情况下,这个作为 key 的字串的长度是 32 个字符。这个 key 还可以在 .env 环境配置文件中设置。如果你没有将 .env.example 文件改名为 .env,那就现在就做吧。如果应用的 key 没有被配置,会话和其他需要加密的数据将不安全!
终端执行:
php artisan key:generate
下面就是数据库的配置。根目录/config/database.php.小编用的数据库是mysql。所以配置如下
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'laravel'), 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', 'secret'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ],
题外话:小编中途未保存,也是好醉了。下面几天认认真真的折腾Laravel框架。加油。博客会跟上的。
版权声明:本文为博主原创文章,未经博主允许不得转载。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
