laravel / database
为您的非Laravel项目获取Laravel数据库。基于 illuminate/database 构建,提供迁移、种子和Artisan支持
Requires
- php: ^7.4|^8
- illuminate/cache: ^8
- illuminate/database: ^8
- illuminate/events: ^8
- illuminate/filesystem: ^8
- illuminate/pagination: ^8
- league/flysystem: ^1.0
- psy/psysh: ^0.10.4
- symfony/process: ^5
- vlucas/phpdotenv: ^5
Requires (Dev)
- doctrine/dbal: ~2.10
- illuminate/console: ^8
- illuminate/view: ^8
- laravel/helpers: ^1
Suggests
- doctrine/dbal: Allow renaming columns and dropping SQLite columns.
README
为您的非Laravel项目提供完整的Laravel数据库功能,为 Illuminate Database 添加迁移、种子和Artisan支持。
它使 artisan 命令行工具与
Available commands:
db Start a new database CLI session
dump-autoload Regenerate framework autoload files
env Display the current framework environment
help Display help for a command
inspire Display an inspiring quote
list List commands
migrate Run the database migrations
serve Serve the application on the PHP development server
tinker Interact with your application
db
db:seed Seed the database with records
db:wipe Drop all tables, views, and types
make
make:command Create a new Artisan command
make:controller Create a new controller class
make:factory Create a new model factory
make:migration Create a new migration file
make:model Create a new Eloquent model class
make:seeder Create a new seeder class
migrate
migrate:fresh Drop all tables and re-run all migrations
migrate:install Create the migration repository
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:rollback Rollback the last database migration
migrate:status Show the status of each migration
vendor
vendor:publish Publish any publishable assets from vendor packages
Laravel 是一个具有表达性、优雅语法的Web应用框架。我们从其中提取了数据库功能,使其可用于其他框架。
Illuminate Database 组件是一个完整的PHP数据库工具包,提供表达性查询构建器、ActiveRecord风格ORM和架构构建器。它目前支持MySQL、Postgres、MSSQL Server和SQLite。我们将它与 Illuminate FileSystem 和 Illuminate Console 结合起来,使Artisan能够与数据库相关命令一起工作。
安装
安装Composer
Laravel Database 使用 Composer 管理其依赖关系。首先,下载一个 composer.phar
的副本。一旦您有了PHAR存档,您可以将它保留在本地项目目录中,或者将其移动到 usr/local/bin
以在系统上全局使用。在Windows上,您可以使用Composer的 Windows安装程序。
安装Laravel Database
在您的终端中运行Composer create-project命令来安装Laravel Database
composer create-project laravel/database --prefer-dist
使用说明
从您的公共 index.php
文件中,在 bootstrap
文件夹中包含 autoload.php
,这内部使用Composer自动加载器。这启用了所有db相关类的懒加载。它不会启动数据库引擎,直到您调用DB相关类之一。
添加更多组件
有关如何添加更多Laravel组件或兼容的第三方服务提供商等的说明,请阅读 app/config/app.php
文件中的注释
实用用法示例
- Restler应用程序Eloquent模板 使restler框架应用程序能够利用 eloquent 的力量和优雅
官方文档
整个框架的文档可以在 Laravel网站 上找到。从那里参考所有数据库相关部分。
致谢
Laravel Database的所有荣誉都属于Laravel框架的开发者。我们只是在这里将这些组件组合起来
贡献
有关此集成的问题和拉取请求应提交到 laravel/database 存储库。
许可证
Laravel Database是开源软件,许可协议为 MIT许可证