Laravel 3.x 是框架发展历程中的重要版本,主要特性如下:
1. 路由系统
-
支持基础路由定义与闭包路由
-
示例:
phpRoute::get('user/profile', function() { return '用户主页'; });
2. Eloquent ORM 雏形
-
提供
Eloquent作为独立扩展包(非默认集成) -
基础模型操作:
phpclass User extends Eloquent {} $users = User::all();
3. 视图系统
-
使用
View::make()渲染模板 -
支持基础数据传递:
phpreturn View::make('profile')->with('name', 'Taylor');
4. 数据库迁移
-
首次引入迁移系统(Schema Builder)
-
基础表操作:
phpSchema::create('users', function($table) { $table->increments('id'); $table->string('email')->unique(); });
5. IoC 容器
-
依赖注入容器初步实现
-
示例绑定:
phpIoC::bind('mailer', function() { return new Mailer; });
6. 命令行工具(Artisan)
-
提供基础命令行操作
-
支持迁移执行:
bashphp artisan migrate
7. 扩展包支持
-
通过
bundles机制管理扩展 -
注册示例:
phpBundle::register('backup');
8. 安全特性
-
基础
CSRF防护 -
输入数据过滤:
phpInput::get('email', 'default@example.com');
版本局限性
- 无命名空间支持(PHP 5.2 兼容)
- 无现代 Blade 模板引擎
- 无中间件机制
- 扩展包依赖手动加载
提示:Laravel 3.x 已于 2013 年停止维护,建议使用新版框架以获得完整功能支持。