laravel入门中文教材
laravel入门知识点整理

laravel⼊门知识点整理作为PHP最常⽤的框架之⼀,Laravel的框架⽬录布置得尤其清晰,适⽤于各种类型的项⽬开发。
今天来记录下laravel⼊门需要熟悉的知识点。
1、其中,public/index.php是项⽬的⼊⼝⽂件2、1)config⽬录该⽂件夹下⾯,包含的是各种配置⽂件。
包括mysql数据库连接信息,redis,⾃定义的配置⽂件信息等等2).env⽂件⽤法参考:env('DB_HOST','192.168.1.223')说明:优先使⽤.env⽂件中配置的DB_HOST对应的值,如果.env中没有配置,则使⽤这⾥设置的默认值'192.168.1.223'3)⽤法参考config('redis_keys.redis_keys.all_follow_user')3、4、1、routes⽬录routes⽬录包含了应⽤定义的所有路由。
Laravel 默认提供了四个路由⽂件⽤于给不同的⼊⼝使⽤:web.php、api.php、 console.php 和channels.php。
除此之外,我们还可以⾃定义路由⽂件。
这⾥介绍两个⽐较重要的官⽅提供的默认路由⽂件web.php和api.php1)web.php⽂件包含的路由通过 RouteServiceProvider 引⼊,都被约束在 web 中间件组中,因⽽⽀持 Session、CSRF 保护以及 Cookie 加密功能,如果应⽤⽆需提供⽆状态的、RESTful 风格的 API,那么路由基本上都要定义在 web.php ⽂件中2)api.php⽂件包含的路由通过 RouteServiceProvider 引⼊,都被约束在 api 中间件组中,因⽽⽀持频率限制功能,这些路由是⽆状态的,所以请求通过这些路由进⼊应⽤需要通过 token 进⾏认证并且不能访问 Session 状态。
2、路由定义稍微复杂⼀点的情况:3、RouteServiceProvider⽂件包含的路由通过 RouteServiceProvider 引⼊5、提到中间件,那⼀定离不开app/Http/Kernel.php这个⽂件1) kernelKernel 中定义了重要的中间件列表,所有的请求 request 在被应⽤处理前,都必须经过这些中间件,筛过⼀遍后,才会被决定如何处理。
Laravel 5.5 入门教程6

Laravel 5.5 入门教程By IT崖柏图Mail 973714522@出自布尔教育PHP高端教育培训21 章功能细化21.1 登陆状态在 view 层 , 判断用户是否登陆或者我们还可以使用身份快捷认证,如:21.2 分页功能中使用 paginate 方法。
代码如下:如何渲染样式在Blade模板上?附加参数到分页链接中方法:```php{{ $users->fragment('foo')->links() }}然而,自定义分页视图最简单的方法是通过vendor:publish命令将它们导出到你的resources/views/vendorphp artisan vendor:publish --tag=laravel-pagination这个命令将视图放置在 resources/views/vendor/pagination 目录中。
这个目录下的 default.blade.php 文件对应于默认分页视图。
你可以简单地编辑这个文件来修改分页的 HTML 。
21.3 JS 验证以发布借款项目为例 , 做 JS 验证第22章自动验证自动验证22.1 验证案例第1个参数为Request对象,第2个参数为验证规则验证规则验证规则为关联数组,语法如下:借款验证案例:验证未通过的检测,以money为例22.2 自定义错误信息如果验证未通过,需要自定义错误信息,只需在第3个参数中传递.模板中使用22.3 手动验证,也可以手动来创建一个验证对象22.3 表单授权验证令来创建表单请求类:控制器中使用,需要引入自己创建的Request对象,与laravel自带的Request对象使用方法一致,只不过是加上了自己的验证规则22.4 自定义验证规则Laravel 目录中一旦创建了规则,我们就可以定义它的行为。
规则对象包含两个方法: passes 和 message 。
passes 方法接收属性值和名称,并根据属性值是否符合规则而返回 true 或者 false。
Laravel 5.5 入门教程4

Laravel 5.5 入门教程By IT崖柏图Mail 973714522@出自布尔教育PHP高端教育培训18章投资功能18.1 首页展示路由: Route::get('/','IndexController@index');view:span18.2 投标页展示路由:Route::get('pro/{pid}',"ProController@pro");控制器:public function pro($pid){view:18.3 投资表及迁移文件投标表 :bids字段类型说明bid primary key 主键uid integer用户 uidpid integer项目 pidtitle string项目名称money integer投标金额pubtime integer投标时间创建迁移文件:php artisan make:migration create_table_bids --create=bids执行迁移命令: php artisan migrate18.4 在线投标view:</路由:Route::post('touzi/{pid}',"ProController@touzi");生成Model: php artisan make:model Bid//按照约定修改class Bid extends Model{写入数据到投资表:写入成功,再次修改 touzi方法,投资的钱,不能大于项目剩余可投的钱,一旦项目的钱,等于已招标的钱,修改状态为2,还款中,状态大于1的项目,不能再投钱,停止招标;18.5 还款表与收益表投标完成后 , 借款人每月要还 "本 + 息", 投资人每天要收利息.因此,我们再建2张表.还款表 :hks字段类型说明hid primary key 主键uid integer用户 uidpid integer项目 pidtitle string项目名称amount integer每月还款金额paydate date账单日status tinyint是否已还生成迁移文件:php artisan make:migration create_table_hks --create=hks执行迁移命令: php artisan migrate18.6 生成月账单** 为借款者生成还款记录 **当投资完成的瞬间,由 projects 中的借款金额/借款周期/利率,算出借款人每月几号应还多少钱?18.7 生成预期收益投资完成后,生成用户预期收入表,做定时任务,根据预期收益表 ** 每天 ** 给投资者产生利息收益,写入收益表;预期收益表 tasks:字段类型说明tid primary key 主键uid integer用户 uidpid integer项目 pidtitle string项目名称amount integer每天应收的利息enddate date收利息截止日生成迁移文件: php artisan make:migration create_table_tasks --create=tasks执行迁移命令: php artisan migtate18.8 生成收益每天收益表 :grows字段类型说明gid primary key主键uid integer用户 uidpid integer项目 pidtitle string项目名称amount integer每天的利息paytime date收益日期生成控制器文件: php artisan make:controller GrowController --plain添加路由: Route::get('payrun','GrowController@run');18.9 借款者还款账单18.10 我的投资写路由:18.11 我的收益。
Laravel框架学习教程

Laravel框架学习教程Chapter 1: Introduction to Laravel FrameworkLaravel is a PHP web application framework that follows the Model-View-Controller (MVC) architectural pattern. It provides a robust set of tools and features that make web development faster and more efficient. In this chapter, we will explore the key concepts and features of the Laravel framework.1.1 Installation and SetupTo get started with Laravel, you need to install it on your local development environment. Laravel can be installed either via Composer or by downloading the Laravel installer. Once installed, you can create a new Laravel project using the command line interface. We will also cover the configuration process and explain how to set up a local development server.1.2 Routing and MVCLaravel offers a powerful routing system that allows you to define the URLs and endpoints for your web application. We will explain how to create routes for different HTTP methods and how to handle dynamic parts of the URL. Furthermore, we will dive into the MVC pattern and discuss how Laravel separates the application logic into controllers, models, and views.1.3 Blade Templating EngineBlade is the built-in templating engine of Laravel, which provides a convenient and expressive way to create views. We will explore the syntax and features of Blade, including template inheritance, control structures, and loops. Additionally, we will discuss how to pass data from the controller to the view and how to use Blade directives for conditional rendering and form input handling.Chapter 2: Database and Eloquent ORMIn this chapter, we will focus on database management and the Eloquent ORM, which is Laravel's database abstraction layer. We will cover various aspects of database operations and demonstrate how to interact with the database using Eloquent models.2.1 Database ConfigurationBefore working with databases in Laravel, you need to configure the database connection settings. We will explain how to set up the database configuration file and specify the connection parameters. Additionally, we will discuss different database management systems supported by Laravel, such as MySQL, SQLite, and PostgreSQL.2.2 Migrations and SeedingLaravel provides a convenient way to handle database schema changes through migrations. We will illustrate how to create, run, and rollback migrations to keep the database schema in sync with the application code. Moreover, we will explain the concept of seeding the database with predefined data using Laravel's seeder classes.2.3 Eloquent ORMThe Eloquent ORM makes database interactions effortless by enabling you to work with database records as objects. We will demonstrate how to define Eloquent models, establish relationships between models, and perform common database operations, including querying, inserting, updating, and deleting data. Furthermore, we will discuss advanced features like eager loading, scopes, and mutators.Chapter 3: Authentication and AuthorizationSecuring web applications is essential for protecting user data and ensuring access control. In this chapter, we will explore Laravel's built-in authentication and authorization features, which simplify the implementation of user registration, login, and access control.3.1 User AuthenticationLaravel provides a comprehensive authentication system that supports various authentication methods, such as email and password, socialite integration, and API token authentication. We will explain how to set up the authentication configuration, create authentication routes, and implement user registration, login, and password reset functionality.3.2 User AuthorizationLaravel's authorization features allow you to define fine-grained access control for different user roles and permissions. We will discusshow to define authorization policies, authorize actions in controllers, and perform role-based access control. Additionally, we will explore how to use gates and policies for more complex authorization scenarios.3.3 MiddlewareLaravel's middleware mechanism enables you to apply logic before or after the execution of a request. We will explain how to create custom middleware and register them in the application. Moreover, we will discuss how to use middleware for various purposes, such as authentication, authorization, form validation, and request transformation.Chapter 4: Testing and DebuggingTesting and debugging are crucial parts of the development process to ensure the quality and reliability of the application. In this chapter, we will cover Laravel's testing and debugging tools, including unit testing, feature testing, logging, and debugging techniques.4.1 Testing FundamentalsLaravel provides a robust testing framework that facilitates unit testing and feature testing. We will explain the basics of writing tests in Laravel, including creating test cases, defining assertions, and running tests. Moreover, we will discuss different testing approaches, such as test-driven development (TDD) and behavior-driven development (BDD).4.2 Unit TestingUnit testing focuses on testing individual units or components of the application in isolation. We will demonstrate how to write unit tests for Laravel's models, controllers, and services using PHPUnit, the default testing library integrated into Laravel. We will also discuss mocking and dependency injection techniques to isolate dependencies in unit tests.4.3 Feature TestingFeature testing helps ensure that the application behaves correctly from a user's perspective. We will show how to write feature tests that simulate user interactions, such as filling out forms and clicking buttons. Additionally, we will discuss testing APIs and handling HTTP requests and responses in feature tests.4.4 Logging and DebuggingLaravel provides a flexible logging system that allows you to log events and debug information for troubleshooting purposes. We will explain how to configure the logging channels, write log messages, and retrieve log entries. Furthermore, we will explore Laravel's debugging tools, including the built-in error handling and exception handling mechanisms.Chapter 5: Advanced TopicsIn this final chapter, we will delve into some advanced topics that further extend the capabilities of Laravel. We will cover topics like caching, queuing, event handling, and package development.5.1 CachingCaching is a technique to store frequently accessed data in memory for faster retrieval. Laravel provides a unified API for various caching drivers, such as in-memory caching, file caching, and database caching. We will explain how to use Laravel's caching system to cache query results, HTML fragments, and even entire pages.5.2 Queues and JobsQueues provide a way to defer time-consuming or resource-intensive tasks and process them asynchronously in the background. We will discuss how to configure Laravel's queue system, create and dispatch jobs, and set up workers to process queued jobs. Additionally, we will explore different queue drivers and queue management tools.5.3 Event HandlingLaravel's event system allows you to decouple components and trigger actions based on specific events. We will explain how to define and dispatch events, create listeners to handle events, and implement event subscribers. Furthermore, we will discuss event broadcasting and using third-party event libraries.5.4 Package DevelopmentLaravel's modular architecture makes it easy to develop and distribute reusable packages. We will explore the process of creating Laravel packages, including setting up package structure, defining service providers, registering routes and assets, and publishing package resources. Moreover, we will discuss package testing and versioning considerations.ConclusionIn this comprehensive Laravel tutorial, we have covered various aspects of the Laravel framework, from the basics of installation and setup to more advanced topics like authentication, testing, and package development. By mastering Laravel, you can build robust and scalable web applications with ease. Stay curious, keep learning, and unleash the full potential of Laravel.。
laravel经典用法

laravel经典用法"Laravel经典用法"文章Laravel是一个充满活力和功能丰富的PHP框架,被广泛用于开发网站和Web应用程序。
它简化了开发过程,并提供了许多有用的功能和工具,使开发者能够更快速地构建高质量的应用程序。
在本文中,我们将探讨一些Laravel的经典用法,帮助开发者深入理解并有效地使用这个强大的框架。
1. 路由(Routing)- Laravel提供了强大灵活的路由功能,使用路由可以定义URL和应用程序代码之间的映射关系。
可以使用闭包、控制器方法和资源控制器来处理不同的路由请求。
通过路由,可以轻松地定义自定义URL结构,实现RESTful风格的API。
2. 控制器(Controllers)- 控制器是Laravel中处理请求的核心部分。
它们负责根据路由将请求分派给适当的代码,并处理业务逻辑。
通过控制器,可以将应用程序的不同功能模块封装到不同的方法中,使代码更加有序和易于维护。
3. 模型(Models)- 模型是Laravel中的数据层,它允许开发者在数据库表之间建立关系,并使用Eloquent ORM(对象关系映射)进行更强大的数据库操作。
通过模型,可以轻松地定义数据表之间的关联关系,并使用强大的查询构建器来执行高级数据库查询。
4. 视图(Views)- 视图是Laravel中负责处理用户界面的部分。
通过将HTML和PHP代码分开,可以更好地组织和管理应用程序的用户界面。
Laravel提供了简单易用的Blade模板引擎,使开发者可以轻松地创建模板和部件,实现代码复用,提高应用程序的可维护性。
5. 中间件(Middleware)- 中间件是Laravel的一个非常强大和重要的概念。
它是一个位于请求和响应之间的代码层,可以在请求到达控制器之前或响应发送到浏览器之前执行一些处理。
中间件可以用于身份验证、日志记录、请求过滤等各种目的,提供了更好的控制和安全性。
Laravel系列入门教程(一)

Laravel系列⼊门教程(⼀)热烈庆祝 Laravel 5.5 LTS 发布!实际上 Laravel 上⼀个 LTS 选择 5.1 是⾮常不明智的,因为 5.2 增加了许许多多优秀的特性。
现在好了,⼤家都⽤最新的长期⽀持版本 5.5 吧!Laravel 5.5 中⽂⽂档:默认条件你应该懂得 PHP ⽹站运⾏的基础知识,并且拥有⼀个完善的开发环境。
跟随本教程⾛完⼀遍,你将会得到⼀个基础的包含登录、后台编辑、前台评论的简单 blog 系统。
Tips1. 环境要求:PHP 7.0+,MySQL 5.1+2. 本教程不推荐完全不懂 PHP 与 MVC 编程的⼈学习,Laravel 的学习曲线不仅仅是陡峭,⽽且耗时很长,请先做好⼼理准备。
3. 这不是 “⼀步⼀步跟我做” 教程。
本教程需要你付出⼀定的⼼智去解决⼀些或⼤或⼩的隐藏任务,以达到真正理解 Laravel 运⾏逻辑的⽬的。
4. 我使⽤ Safari 截图是为了好看,你们在开发时记得选择 Chrome 哦~开始学习1. 安装许多⼈被拦在了学习 Laravel 的第⼀步:安装。
并不是因为安装有多复杂,⽽是因为【众所周知的原因】。
在此我推荐⼀个 composer 全量中国镜像:。
启⽤ Composer 镜像服务作为本教程的第⼀项⼩作业请⾃⾏完成哦。
镜像配置完成后,在终端(Terminal 或 CMD)⾥切换到你想要放置该⽹站的⽬录下(如 C:\wwwroot、/Library/WebServer/Documents/、/var/www/html、/etc/nginx/html 等),运⾏命令:composer create-project laravel/laravel learnlaravel5 ^5.5然后,稍等⽚刻,当前⽬录下就会出现⼀个叫 learnlaravel5 的⽂件夹,安装完成啦~2. 运⾏为了尽可能地减缓学习曲线,推荐⼤家使⽤ PHP 内置 web server 驱动我们的⽹站。
laravel框架入门

laravel框架⼊门本⽂摘⾃⽹络,个⼈感觉写的很不错,决定收藏⼀下纯属本⼈学习之⽤本⽂介绍如何开始使⽤ Laravel。
读完本⽂,你将学到:如何安装 Laravel,新建 Laravel 程序,如何连接数据库;Laravel 程序的基本⽂件结构;MVC(模型,视图,控制器)和 REST 架构的基本原理;如何快速⽣成 Laravel 程序⾻架;1 前提条件本⽂针对想从零开始开发 Laravel 程序的初学者,不需要预先具备任何的 Laravel 使⽤经验。
不过,为了能顺利阅读,还是需要事先安装好⼀些软件:PHP 5.4 及以上版本包管理⼯具 Composer 。
想深⼊了解 Composer,请阅读 Composer 指南。
官⽹:,中⽂⽹:SQLite3 数据库Laravel 是使⽤ PHP 语⾔开发的⽹页程序框架。
如果之前没接触过 PHP,学习 Laravel 可要深下⼀番功夫。
⽹上有很多资源可以学习PHP:2 Laravel 是什么?Laravel 是使⽤ PHP 语⾔编写的⽹页程序开发框架,⽬的是为开发者提供常⽤组件,简化⽹页程序的开发。
只需编写较少的代码,就能实现其他编程语⾔或框架难以企及的功能。
经验丰富的 PHP 程序员会发现,Laravel 让程序开发变得更有乐趣。
Laravel 哲学Laravel 是⼀套富有表达性且具有简洁语法的⽹页应⽤程序框架。
我们认为开发过程应该是愉悦且有创造性的体验。
Laravel 努⼒减少开发过程中的不便,因此我们提供了验证(authentication)、路由(routing)、sessions、缓存(caching)等开发过程中经常⽤到的⼯具或功能。
Laravel ⽬标是给开发者创造⼀个愉快的开发过程,并且不牺牲应⽤程序的功能性。
快乐的开发者才能创造最棒的代码。
为了这个⽬的,我们竭取了各框架的优点集中到 Laravel 中,这些框架包括并不局限于 Ruby on Rails、 MVC 和 Sinatra 等。
laravel学习知识点

第一章组建开发与composer使用突出特点:组件化开发、IoC容器技术、分布式应用框架设计PHP开发规范:PSR0-PSR4PSR-4规范的目录不需要添加命名空间PSR-0规范的目录需要添加命名空间Classmap 会扫描指定目录的所有.php 和.inc文件,并加载到vendor/composer/autoload_classmap.php文件中,在该文件中实现一个具体类与文件映射的关联数组,也可以直接精确指定一个文件Composer 命令行简介Composer list 获取帮助信息Composer init 以交互方式填写composer.json文件信息Composer install 从当前目录读取composer.json文件,处理依赖关系,并安装到verdor目录下Composer update 获取依赖的最新版本升级composer.lock文件Composer require 添加新的依赖包到composer.json文件中并执行更新Composer search 在当前项目中搜索依赖包Composer show 列举所有可用的资源包Composer validate 检测composer.json文件是否有效Composer self-update 将composer工具更新到最新的版本Composer create-project 基于composer创建一个新的项目Composer dump_autoload 在添加新的类和目录映射时更新autoloader构建过程五个步骤:项目初始化、路由组件添加、控制器模块添加、模型组建添加和视图组件添加添加模型组件:两种操作数据库的方式:一种是查询构造器方式两一种是Eloquent ORM方式Eloquent ORM方式创建数据库添加数据库配置信息、启动Eloquent ORM模块、创建model类和通过model 类操作数据库数据库配置:www\lara\config\database.php<?phpReturn [‘driver’ =>‘mysql’,‘host’ =>‘localhost’,‘database’ =>‘lara’,‘username’ =>‘root’,‘password’ =>‘root’,‘charset’ =>‘utf8’,‘collation’ =>‘utf8_general_ci’,‘prefix’ =>‘’];?>视图组建的使用四步骤:一是添加视图模板文件和编译文件的存储路径二是对视图进行相关配置和服务注册三是使用视图文件四是创建视图模板文件第二章laravel框架安装与调试环境建立Phpstudy包含:四种服务器Apache 、Nginx、IIS、LighttpdLaravel框架的安装1.通过composer包安装(有些情况无法下载,国内防火墙拦截了)2.一键安装包安装Phpstudy 单击“其他选项菜单”,后选择“php版本切换”,可以选择php版本。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
##3 新建 Laravel 程序 阅读本文时,最好跟着一步一步操作,如果错过某段代码或某个步骤,程序就可能出错,所以请一步一步跟着 做。
本文会新建一个名为 blog 的 Laravel 程序,这是一个非常简单的博客。
> 文中的示例代码使用 $ 表示命令行提示符,你的提示符可能修改过,所以会不一样。在 Windows 中,提 示符可能是 c:\source_code>。
请确定把 `~/.composer/vendor/bin` 路径放置于您的 PATH 里, 这样 laravel 可执行文件才能被命 令行找到, 以后您就可以在命令行下直接使用 laravel 命令.
安装并且配置成功后, 可以使用命令 `laravel new` 在您指定的目录下创建一份全新安装的 Laravel 应 用, 如这样的调用: `laravel new blog` 将会在当前目录下创建一个叫 blog 的目录, 此目录里面存 放着全新安装的 Laravel 应用, 此方法跟其他方法不一样的地方在于是提前安装好所有代码依赖的, 您无 需再通过 `composer install` 安装, 速度一下子提高了很多.
更多资料 https:///huanghua581/laravel-getting-started/wiki
# Laravel 入门
本文介绍如何开始使用 Laravel。
读完本文,你将学到:
* 如何安装 Laravel,新建 Laravel 程序,如何连接数据库; * Laravel 程序的基本文件结构; * MVC(模型,视图,控制器)和 REST 架构的基本原理; * 如何快速生成 Laravel 程序骨架;
###Laravel 哲学
* Laravel 是一套富有表达性且具有简洁语法的网页应用程序框架。我们认为开发过程应该是愉悦且有创造 性的体验。Laravel 努力减少开发过程中的不便,因此我们提供了验证(authentication)、路由 (routing)、sessions、缓存(caching)等开发过程中经常用到的工具或功能。
Laravel 框架使用 composer 来执行安装及管理依赖。如果还没有安装它的话,请先从 安装 Composer 开始吧。
安装之后,您可以通过终端执行下列命令来安装 Laravel:
``` $ composer create-project laravel/laravel your-project-name --prefer-dist ```
###3.1 安装 Laravel 打开命令行:在 Mac OS X 中打开 Terminal.app,在 Windows 中选择“运行”,然后输入“cmd.exe”。下
文中所有以 $ 开头的代码,都要在命令行中运行。先确认是否安装了 PHP 5.4 或者以上的版本:
> 有很多工具可以帮助你快速在系统中安装 PHP 。Windows 用户可以使用 WAMP,Mac OS X 用户可以使 用 MAMP。
``` $ composer create-project laravel/laravel blog --prefer-dist ```
这个命令会在文件夹 blog 中新建一个 Laravel 程序。
> 执行 laravel new -h 可以查看新程序生成器的所有命令行选项。
生成 blog 程序后,进入该文件夹:
###3.2 创建 Blog 程序 Artisan 是 Laravel 内建的命令行工具,它提供了一些有用的命令协助您开发,它是由强大的 Symfony Console 组件所驱动。
打开终端,进入有写权ew blog ```
或者
``` $ sqlite3 --version ```
安装 Laravel , 通过 Laravel 安装器
首先, 使用 Composer 全局下载并安装 Laravel/installer:
``` $ composer global require "laravel/installer=~1.1" ```
with XCache v2.0.1, Copyright (c) 2005-2012, by mOo ```
如果你还没安装 PHP,请访问 / ,找到针对所用系统的安装方法。
很多类 Unix 系统都自带了版本尚新的 SQLite3。Windows 等其他操作系统的用户可以在 SQLite3 的网 站上找到安装说明。然后,确认是否在 PATH 中:
``` $ cd blog ```
blog 文件夹中有很多自动生成的文件和文件夹,组成一个 Laravel 程序。本文大部分时间都花在 app 文 件夹上。下面简单介绍默认生成的文件和文件夹的作用:
文件/文件夹 | 作用 ----- | ----app/ | 包含了站点的 controllers(控制器),models(模型),views(视图)和 assets(资源)。 这些是网站运行的主要代码,你会将你大部分的时间花在这些上面。本文主要关注的是这个文件夹。 bootstrap | 用来存放系统启动时需要的文件,这些文件会被如 index.php 这样的文件调用。 public | 这个文件夹是唯一外界可以看到的,是必须指向你 web 服务器的目录。它含有 laravel 框架核 心的引导文件 index.php,这个目录也可用来存放任何可以公开的静态资源,如 css,Javascript,images 等。 vendor | 用来存放所有的第三方代码,在一个典型的 Laravel 应用程序,这包括 Laravel 源代码及其 相关,并含有额外的预包装功能的插件。 app/config/ | 配置应用程序的运行时规则、 数据库、 session 等等。包含大量的用来更改框架的各个 方面的配置文件。大部分的配置文件中返回的选项关联 PHP 数组。 app/config/app.php | 各种应用程序级设置,即时区、 区域设置(语言环境)、 调试模式和独特的加密 密钥。 app/config/auth.php | 控制在应用程序中如何进行身份验证,即身份验证驱动程序。 app/config/cache.php | 如果应用程序利用缓存来加快响应时间,要在此配置该功能。 app/config/compile.php | 在此处可以指定一些额外类,去包含由‘artisan optimize’命令声称的 编译文件。这些应该是被包括在基本上每个请求到应用程序中的类。 app/config/database.php | 包含数据库的相关配置信息,即默认数据库引擎和连接信息。 app/config/mail.php | 为电子邮件发件引擎的配置文件,即 SMTP 服务器,From:标头 app/config/session.php | 控制 Laravel 怎样管理用户 sessions,即 session driver, session lifetime。 app/config/view.php | 模板系统的杂项配置。 app/controllers | 包含用于提供基本的逻辑、 数据模型交互以及加载应用程序的视图文件的控制器类。 app/database/migrations/ | 包含一些 PHP 类,允许 Laravel 更新当前数据库的架构并同时保持所 有版本的数据库的同步。迁移文件是使用 Artisan 工具生成的。 app/database/seeds/ | 包含允许 Artisan 工具用关系数据来填充数据库表的 PHP 文件。 app/lang/ | PHP 文件,其中包含使应用程序易于本地化的字符串的数组。默认情况下目录包含英语语言 的分页和表单验证的语言行。 app/models/ | 模型是代表应用程序的信息(数据)和操作数据的规则的一些类。在大多数情况下,数据 库中的每个表将对应应用中的一个模型。应用程序业务逻辑的大部分将集中在模型中。 app/start/ | 包含与 Artisan 工具以及全球和本地上下文相关的自定义设置。 app/storage/ |该目录存储 Laravel 各种服务的临时文件,如 session, cache, compiled view templates。这个目录在 web 服务器上必须是可以写入的。该目录由 Laravel 维护,我们可以不关心。
Laravel 是使用 PHP 语言开发的网页程序框架。如果之前没接触过 PHP,学习 Laravel 可要深下一番功 夫。网上有很多资源可以学习 PHP:
PHP 语言官方网站: /
##2 Laravel 是什么? Laravel 是使用 PHP 语言编写的网页程序开发框架,目的是为开发者提供常用组件,简化网页程序的开发。 只需编写较少的代码,就能实现其他编程语言或框架难以企及的功能。经验丰富的 PHP 程序员会发现, Laravel 让程序开发变得更有乐趣。
##1 前提条件 本文针对想从零开始开发 Laravel 程序的初学者,不需要预先具备任何的 Laravel 使用经验。不过,为了 能顺利阅读,还是需要事先安装好一些软件:
* PHP 5.4 及以上版本 * 包管理工具 Composer 。想深入了解 Composer,请阅读 Composer 指南 。官网: https:/// , 中文网 : / * SQLite3 数据库
* Laravel 目标是给开发者创造一个愉快的开发过程,并且不牺牲应用程序的功能性。快乐的开发者才能创 造最棒的代码。为了这个目的,我们竭取了各框架的优点集中到 Laravel 中,这些框架包括并不局限于 Ruby on Rails、 MVC 和 Sinatra 等。