laravel 4安装及入门图文教程_php实例

WBOY
Release: 2016-06-07 17:15:59
Original
776 people have browsed it

一.安装Composer

首先你需要安装Composer,Composer是PHP依赖管理工具,Laravel框架就是使用 Composer 执行安装和依赖管理。
注:
(1)若安装Composer出错,在php.ini中开启php_openssl,php_fileinfo扩展,因为Laravel需要。
(2)安装过程中,选择正确的php.exe位置

二.安装Laravel

Composer安装完成后,在cmd中,你的网站目录执行下面命令即可:

<ol class="linenums"><li class="L0">composer create-project laravel/laravel your-project-name</li></ol>
Copy after login


Composer会自动帮你下载Laravel及安装。


三.部署虚拟主机

例如我的项目名称是project:

<ol class="linenums">
<li class="L0"><virtualhost></virtualhost></li>
<li class="L1">DocumentRoot "E:/www/project/public"</li>
<li class="L2">ServerName laravel.dev</li>
<li class="L3">ErrorLog "logs/laravel.log"</li>
<li class="L4">CustomLog "logs/laravel.log" common</li>
<li class="L5">
</ol>
Copy after login


当然,也需要在你的hosts中绑定域名:

<ol class="linenums"><li class="L0">127.0.0.1    laravel.dev</li></ol>
Copy after login


至此,安装完成:

四.实现Hello World

通过路由实现打印Hello World,在app/routes.php中新增:

<ol class="linenums">
<li class="L0">Route::get('test', function()</li>
<li class="L1">{</li>
<li class="L2">return 'Hello World!';</li>
<li class="L3">});</li>
</ol>
Copy after login

因为Laravel模板使用的是Blade,所以在后面的教程才介绍Controller或view相关!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template