electro-modules/illuminate-database
Composer 安装命令:
composer require electro-modules/illuminate-database
包简介
Integrates the Laravel's Illuminate Database Component into the Electro framework
README 文档
README
Integrates the Laravel's Illuminate Database Component into the Electro framework
Introdution
This plugin integrates with PhpKit\ExtPDO and the framework's database subsystem, so that connections defined on the
framework's Connections service are automatically available as Illuminate Database connections.
Installation
Server Requirements
- PHP >= 5.6
- A fully-functional installation of the Electro framework
- Laravel's requirements
Installation
To install this plugin on your application, using the terminal, cd to your app's directory and type:
workman install plugin electro-modules/illuminate-database
For correct operation, do not install this package directly with Composer.
Using the plugin
First, start by injecting the plugin API into your controller (or component, command, migration, etc).
use Electro\Plugins\IlluminateDatabase\DatabaseAPI; class MyController { private $api; function __construct (DatabaseAPI $api) { $this->api = $api; } }
Using the query builder
Example
$this->api->query()->from('products')->where('type','box')->get();
or simply
$this->api->table('products')->where('type','box')->get();
Using the schema builder
Example
use Illuminate\Database\Schema\Blueprint; $this->api->schema()->create ('news', function (Blueprint $table) { $table->increments ('id'); $table->string ('title', 100); });
Facades
This plugin also emulates some common database-related Laravel facades:
DB::method()- equivalent to$api->connection ()->method()Schema::method()- equivalent to$api->schema()->method()
This way, you don't need to inject an API instance to call the query builder or the schema builder.
Note: being an anti-pattern, facades are not recommended for development with Electro.
Be sure to import the related namespaces before using the facades (do not use the original facades, it won't work).
use Electro\Plugins\IlluminateDatabase\DB;use Electro\Plugins\IlluminateDatabase\Schema;
Using Eloquent
To use Eloquent, access your models as usual, but don't forget to base their classes on Electro\Plugins\IlluminateDatabase\BaseModel instead of Illuminate\Database\Eloquent\Model.
Example
use Electro\Plugins\IlluminateDatabase\BaseModel;
class Article extends BaseModel { }
$article = Article::find(1);
Migrations
Available commands
| Command | Description |
|---|---|
make:migration |
Create a new database migration. |
make:seeder |
Create a new database seeder. |
migrate |
Runs all pending migrations of a module, optionally up to a specific version. |
migrate:refresh |
Reset and re-run all migrations. |
migrate:reset |
Rollback all database migrations. |
migration:rollback |
Reverts the last migration of a specific module, or optionally up to a specific version. |
migration:seed |
Run all available seeders of a specific module, or just a specific seeder. |
migration:status |
Print a list of all migrations of a specific module, along with their current status. |
You can also type workman on the terminal to get a list of available commands.
Type worman help xxx (where xxx is the command name) to know which arguments and options each command supports.
License
The Electro framework is open-source software licensed under the MIT license.
Electro framework - Copyright © Cláudio Silva and Impactwave, Lda.
electro-modules/illuminate-database 适用场景与选型建议
electro-modules/illuminate-database 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.18k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 06 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「electro」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 electro-modules/illuminate-database 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 electro-modules/illuminate-database 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 electro-modules/illuminate-database 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
A component-based template engine for PHP web applications
A Composer library installer for the Electro framework
An extensible application base, built on Electro
A set of pages and transactional emails for user login, signup and password reset
A theme for Selenia based on the Open Source Gentelella Bootstrap 3 Admin Template
统计信息
- 总下载量: 2.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-16