# 前言

這是一本 Laravel 4 的入門書，目標是帶你快速瞭解及上手目前最受歡的 PHP 開發框架 Laravel。你不需要學過其他網頁框架，但至少要懂 PHP 及物件導向的基本知識，並且知道 HTML 的標籤怎麼寫。最後，你也必須具備資料庫的基礎知識，及最基本的 SQL CRUD 如何撰寫，雖然在 Laravel 中，你可以一行 SQL 都不用寫，但最好還是瞭解它實際上是如何運作的。

> 框架只是輔助。

## 這本書包含什麼

這本書包含 Laravel 4 的介紹，整個框架中組成的各部份如何互相合作。你會學到 Route 如何設定、View 及 Controller 怎麼實作、如何使用 Blade 建立模版及建立表單。

當然還會知道如何與資料庫互動，你會學到如何使用 Query Builder 及 Eloquent ORM 來操作資料庫、如何使用 Schema Builder 來操作資料表、如何使用 Migrations 來快速遷移資料庫、如何使用 Seeding 功能，快速新增資料到資料庫中。最後，你還會學到如何製作會員登入驗證的機制、如何做在地化 (多國語言)、如何將過多的資料分頁、以及如何寄信。

## 誰適合這本書

特別說明，本書的內容是使用 Laravel 4.2 版，目前 Laravel 最新版本為 5.1 版，5.x 版以後的架構會不太一樣。

這本是 Laravel 的入門書，並不是網站開發的入門書，所以你必須具備網站開發的基本知識，因為 Laravel 是 PHP 框架，當然你就必須要懂 PHP，其他如 HTML、CSS、JavaScript 及資料庫等等，都要有一定的基礎知識。

這本書編寫的內容是在 Mac 底下完成，使用的指令是以 Mac 下的終端機為主，如果你是使用 Windows 作業系統，可能在使用終端機指令時要自行調整。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tony915.gitbook.io/laravel-4-2/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
