search
Homephp教程php手册laravel 4安装及入门图文教程,laravel图文

laravel 4安装及入门图文教程,laravel图文

一.安装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>


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>


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

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


至此,安装完成:

四.实现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>

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

Laravel 41在进行数据库save()时,会自动多出两个字段updated_at与created_at,怎取消

默认情况下,Eloquent 在数据的表中自动地将维护 created_at 和 updated_at 字段。只需简单的添加这些 timestamp 字段到表中,Eloquent 将为您做剩余的工作。如果您不希望 Eloquent 维护这些字段,在模型中添加以下属性:public $timestamps = false;

参考:www.golaravel.com/docs/4.1/eloquent/#timestamps
 

怎查看laravel4的sessionID

建议你安装一下debugbar,在composer.json中require以下:
"barryvdh/laravel-debugbar": "1.*"
 

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.