PHP 之 Laravel 框架安装及相关开源软件
**Laravel 被称为简洁、优雅的PHP开发框架,但第一次接触此框架的人有不少都卡在了安装上,其实在 Linux 下只需要很简单的几步就可以搞定,这里我们以 CentOS 下 PHP + Nginx + Mysql 的环境为例。**首先需要了解 Laravel 安装依赖,比如 Laravel4.2 就有下面的要求:PHP >= 5.4 - MCrypt PHP 扩展最主要的是 PHP 版本,正常安装的话相关扩展应该都会包含另外你的系统需要有 Composer,一个 PHP 依赖管理工具,没装过的可以在这里下载:[https://getcomposer.org/download/](https://getcomposer.org/download/)然后把composer.phar文件改名为composer放在/usr/bin目录下接下来设置 composer 镜像地址```composer config -g repositories.packagist composer http://packagist.phpcomposer.com```最后就是用 composer 安装 laravel 了。版本、安装路径都可以在参数中指定,这里我们安装的是4.2版本,放在nginx网站根目录下```composer create-project laravel/laravel=4.2 /usr/local/nginx/html/laravel4.2 --prefer-dist```安装成功后记得更改 [Laravel](http://news.oneapm.com/tag/laravel/) 目录权限```chmod 777 -R /usr/local/nginx/html/laravel4.2```不出意外的话,在浏览器上可以访问到 Laravel 的欢迎页面了----------只有框架当然不够,还有许多内容需要添加,在网上能够找到一些基于 Laravel 的开源软件,我们试一个在 Laravel5.1 上简单开发的博客程序,就叫 laravel51,在github 上就可以下载:[https://github.com/mangoim/laravel51](https://github.com/mangoim/laravel51)安装步骤也很简单,先用git拉下来```git clone https://github.com/mangoim/laravel51.git```在 mysql 上创建数据库 laravel51,然后导入sql文件```mysql -u root -p laravel51 < /usr/local/nginx/html/laravel51/laravel51.sql```修改数据库脚本中配置```vim /usr/local/nginx/html/laravel51/config/database.php```改成mysql中的字段,username 和 password 根据你本地 mysql 的设置来修改```'mysql' => [ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'laravel51', 'username' => 'root', 'password' => '123456', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ],```在 nginx 下配置一个新的端口```vim /usr/local/nginx/conf/nginx.conf```这里我设置为 7070 端口重启一下服务器,浏览器在 7070 下访问 index.php,应该会有这样的页面后台功能也开发好了一部分,访问 index.php/admin,用户名:roy 密码:123456----------最后推荐一些有用的网址:最重要的就是官方文档了,想要深入了解 Laravel 的需要好好看看:http://www.golaravel.com/laravel/docs另外有一个国内开发者写的入门教程,适合于新人上手:https://lvwenhan.com/laravel/432.html下面是一个基于Laravel4.2的 CMS,其实许多这类项目都是个人用业余时间开发的,大家用熟Laravel之后也可以自己做一个,万一火了呢。(http://simpla.simplahub.com/;https://git.oschina.net/ken.yang/Simpla)**[OneAPM for PHP](http://www.oneapm.com/ai/php.html?utm_source=Community&utm_medium=Article&utm_term=PHP%E4%B9%8BLaravel%E6%A1%86%E6%9E%B6%E5%AE%89%E8%A3%85%E5%8F%8A%E7%9B%B8%E5%85%B3%E5%BC%80%E6%BA%90%E8%BD%AF%E4%BB%B6&utm_campaign=AiPHPArti&from=jsclgcmesw) 能够深入到所有 PHP 应用内部完成[应用性能管理](http://www.oneapm.com/) 能够深入到所有 PHP 应用内部完成应用性能管理和监控,包括代码级别性能问题的可见性、性能瓶颈的快速识别与追溯、真实用户体验监控、服务器监控和端到端的应用性能管理。想阅读更多技术文章,请访问 OneAPM [官方技术博客](http://news.oneapm.com/?utm_source=Community&utm_medium=Article&utm_term=PHP%E4%B9%8BLaravel%E6%A1%86%E6%9E%B6%E5%AE%89%E8%A3%85%E5%8F%8A%E7%9B%B8%E5%85%B3%E5%BC%80%E6%BA%90%E8%BD%AF%E4%BB%B6&utm_campaign=AiPHPArti&from=jsclgcmesw)。****本文转自 [OneAPM 官方博客](http://news.oneapm.com/)**

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...

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.

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