PropelLaravel

为Laravel框架进行Propel 2集成。(Propel 2 integration for Laravel framework.)

  • 所有者: propelorm/PropelLaravel
  • 平台: Linux, Mac, Windows
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

propel-laravel

用于Laravel框架的Propel2集成。仅支持5.x版本。 4.x版本可以在当前软件包的 初始开发人员 的库中找到。

用法

首先:您需要了解当前的软件包正处于重大的开发阶段。 我们试图保持1. *分支稳定并经过1M测试,保证这些开发者情绪稳定。Propel2似乎相当稳定,但仍在开发中,目前它要求您的安装必须具有最小的稳定性是alpha。打开你的 composer.json 并在 config 部分之后写入:

"config": {
    "preferred-install": "dist"
},
"minimum-stability": "alpha"

需要使用以下命令的Composer包:

composer require propel/propel-laravel

在更新composer之后,将ServiceProviders添加到 app/config/app.php 中的providers数组中。

Propel\PropelLaravel\GeneratorServiceProvider::class,
Propel\PropelLaravel\RuntimeServiceProvider::class,

下一步是将示例配置复制到您的 app/config 目录。

php ./artisan vendor:publish --provider 'Propel\PropelLaravel\RuntimeServiceProvider'

在提供的配置中:模式文件位于 database/文件夹中, 模型生成到 app/models ,迁移到 app/database/migrations

现在您可以通过工匠使用Propel命令,例如:

php ./artisan propel:model:build

对于propel的新用户,有创建示例 schema.xml 文件的命令:

php ./artisan propel:schema:create

如果您在现有数据库上尝试Propel2,则可以使用 反向数据库命令:

php ./artisan propel:database:reverse mysql

从版本2.0.0-alpha5开始,配置中有非常棒的配置节点 exclude_tables 它允许你在一个数据库中混合不同的项目表。

小提示:您可以将模式中所有生成的模型的命名空间定义为数据库的属性:

<database … namespace="MyApp\Models">

验证

Package包含Auth驱动程序绑定,它允许存储用户信息并以当前登录用户的身份获取( Auth::getUser())作为推进模型。您需要更改 config/auth.php 中的两个设置:

'driver' => 'propel', //custom auth provider implemented in current package
…
'model' => MyApp\Models\User::class, //classname of user entity

架构创建和模型生成之后,您必须增强您的模型以实现所有laravel Auth要求。通用用户模型似乎如此:

use MyApp\Models\Base\User as BaseUser;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends BaseUser implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword;
    public function getAuthIdentifier()
    {
        return $this->id;
    }
}

静态配置

默认情况下,它会在运行时从主配置 app/config/propel.php 构建配置,但是您可以通过运行来构建静态配置 app/propel/config.php /p>

php ./artisan propel:config:convert

服务

没有提供服务。

Propel通过使用静态方法和自己的服务容器来配置和管理自己,所以没有服务被注册到应用程序中。 实际上, GeneratorServiceProvider 类将Propel任务注入具有前缀 propel的artisan任务列表中: RuntimeServiceProvider 类初始化Propel运行时配置

已知问题

  • Cli命令 propel:database:reverse 将反转的模式文件保存到项目的根目录
  • 初始用户创建时没有模式文件和命令,但它在我们的路线图中,并且将很快到达

作者

Alex Kazynsky写的第一个版本。 现在由 Alexander Zhuralvev Maxim Soloviev 。 非常感谢每位 作者!任何错误报告和拉请求赞赏!

另见

使Propel模型与Laravel Form::model()一起工作,而不使其成为数组

主要指標

概覽
名稱與所有者propelorm/PropelLaravel
主編程語言PHP
編程語言PHP (語言數: 1)
平台Linux, Mac, Windows
許可證MIT License
所有者活动
創建於2015-08-07 16:04:31
推送於2019-03-06 01:52:41
最后一次提交2019-03-06 14:52:40
發布數0
用户参与
星數30
關注者數8
派生數21
提交數57
已啟用問題?
問題數16
打開的問題數8
拉請求數7
打開的拉請求數0
關閉的拉請求數5
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

propel-laravel

Propel2 integration for Laravel framework. Only 5.x versions supported.
4.x version can be found in repo of initial developer of current package.

Usage

First of all: you need to understand that current package is in heavy development.
We try to maintain 1.* branch as stable and tested as it used by 1M of angry developers, which have guns.
Propel2 seems pretty stable, but still in development and currently it require that your
installation must have minimum stability is alpha. Open your composer.json
and write after config section:

"config": {
    "preferred-install": "dist"
},
"minimum-stability": "alpha"

Require this package with composer using the following command:

composer require propel/propel-laravel

After updating composer, add the ServiceProviders to the providers array in app/config/app.php

Propel\PropelLaravel\PropelIntegrationServiceProvider::class,

Next step is copy example config to your app/config directory.

php ./artisan vendor:publish --provider 'Propel\PropelLaravel\RuntimeServiceProvider'

Within provided config: schemas files are located into database/ folder,
models are generated into app/models, migrations into app/database/migrations

You can now use Propel commands via artisan, for example:

php ./artisan propel:model:build

etc.

For new users of propel there is command creating sample schema.xml file:

php ./artisan propel:schema:create

If you are trying Propel2 on existing database — you can use
reverse database command:

php ./artisan propel:database:reverse mysql

Since version 2.0.0-alpha5 there is awesome config node exclude_tables in config,
which allows you to mix different project tables in one database.

Small hint: you can define namespace of all generated models in schema just as attribute of database:

<database … namespace="MyApp\Models">

Auth

Package contains Auth driver binding which allows to store user info and fetch (Auth::getUser()) current logged in user as propel model. You need to change two settings in config/auth.php:

'driver' => 'propel', // custom auth provider implemented in current package
…
'model' => MyApp\Models\User::class, // classname of user entity

After schema creating and model generation you must enhance your model to implement all laravel Auth requirements. Generic user model seems so:

use MyApp\Models\Base\User as BaseUser;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class User extends BaseUser implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, CanResetPassword;

    public function getAuthIdentifier()
    {
        return $this->id;
    }
}

Static Configuration

By default it builds configuration from main config app/config/propel.php in runtime but you may build static config app/propel/config.php by running

php ./artisan propel:config:convert

Services

No service is provided.

Propel configures and manages itself by using static methods and its own service container, so no service is registered into Application.
Actually, the GeneratorServiceProvider class injects Propel tasks into artisan tasks list with prefix propel:
RuntimeServiceProvider class initializes Propel runtime configuration

Known issues

  • Cli command propel:database:reverse save reversed schema file to root of project
  • There isn't schema file and command for initial user creation, but it's in our roadmap and will arrive soon

Authors

First version written by Alex Kazynsky.
Now maintained by Alexander Zhuralvev and
Maxim Soloviev.
Thanks a lot to each author! Any bug reports and pull requests are appreciated!

See also

Make Propel models work with Laravel Form::model() without making it an array