如何在没有Laravel的情况下使用Eloquent ORM?

时间:2022-10-16 07:51:41

Is it possible to use Eloquent without Laravel or does somebody knows a equally easy to use ORM?

是否可以在没有Laravel的情况下使用Eloquent或者是否有人知道同样易于使用的ORM?

3 个解决方案

#1


37  

Yes you can. A while ago Dan Horrigan released a package called Capsule for Laravel 4 which allowed Eloquent to be used independently and with minimal setup. The package itself has been merged with the L4 core so you no longer need to use the package.

是的你可以。不久前,Dan Horrigan发布了一个名为Capsule for Laravel 4的软件包,允许Eloquent独立使用并且设置最少。软件包本身已与L4核心合并,因此您不再需要使用该软件包。

If you refer to the illuminate/database repository there is a nice little introduction on using Eloquent without the framework.

如果您参考照明/数据库存储库,那么在没有框架的情况下使用Eloquent会有一个很好的介绍。

Here is a small excerpt of getting it up and running.

这是一个启动和运行的小摘录。

$capsule = new Illuminate\Database\Capsule($config);

$capsule->bootEloquent();

$capsule->connection()->table('users')->where('id', 1)->first();

Update

更新

Dan Horrigan has since removed his Capsule implementation as it is now built directly into Eloquent. Refer to the above illuminate/database link for more details on how to use Capsule.

Dan Horrigan已经删除了他的Capsule实现,因为它现在直接建立在Eloquent中。有关如何使用Capsule的更多详细信息,请参阅上面的illuminate / database链接。

#2


0  

In Laravel 4.*, Eloquent is automatically independent because it's shipped with Dan Horrigan's Capsule. You don't need to download any extras. For a how to please visit: https://github.com/illuminate/database/blob/master/README.md

在Laravel 4. *中,Eloquent自动独立,因为它与Dan Horrigan的胶囊一起发货。您无需下载任何其他内容。如何访问:https://github.com/illuminate/database/blob/master/README.md

#3


0  

Check out https://github.com/Luracast/Laravel-Database it provides full eloquent support including artisan migrations and more for the latest Laravel 5.2.* components.

查看https://github.com/Luracast/Laravel-Database,它为最新的Laravel 5.2。*组件提供了全面的技术支持,包括工匠迁移等。

It uses capsule and lazy loads the components when they are used.

它在使用时使用胶囊和延迟加载组件。

Disclosure: I'm the author of this repository

披露:我是这个存储库的作者

#1


37  

Yes you can. A while ago Dan Horrigan released a package called Capsule for Laravel 4 which allowed Eloquent to be used independently and with minimal setup. The package itself has been merged with the L4 core so you no longer need to use the package.

是的你可以。不久前,Dan Horrigan发布了一个名为Capsule for Laravel 4的软件包,允许Eloquent独立使用并且设置最少。软件包本身已与L4核心合并,因此您不再需要使用该软件包。

If you refer to the illuminate/database repository there is a nice little introduction on using Eloquent without the framework.

如果您参考照明/数据库存储库,那么在没有框架的情况下使用Eloquent会有一个很好的介绍。

Here is a small excerpt of getting it up and running.

这是一个启动和运行的小摘录。

$capsule = new Illuminate\Database\Capsule($config);

$capsule->bootEloquent();

$capsule->connection()->table('users')->where('id', 1)->first();

Update

更新

Dan Horrigan has since removed his Capsule implementation as it is now built directly into Eloquent. Refer to the above illuminate/database link for more details on how to use Capsule.

Dan Horrigan已经删除了他的Capsule实现,因为它现在直接建立在Eloquent中。有关如何使用Capsule的更多详细信息,请参阅上面的illuminate / database链接。

#2


0  

In Laravel 4.*, Eloquent is automatically independent because it's shipped with Dan Horrigan's Capsule. You don't need to download any extras. For a how to please visit: https://github.com/illuminate/database/blob/master/README.md

在Laravel 4. *中,Eloquent自动独立,因为它与Dan Horrigan的胶囊一起发货。您无需下载任何其他内容。如何访问:https://github.com/illuminate/database/blob/master/README.md

#3


0  

Check out https://github.com/Luracast/Laravel-Database it provides full eloquent support including artisan migrations and more for the latest Laravel 5.2.* components.

查看https://github.com/Luracast/Laravel-Database,它为最新的Laravel 5.2。*组件提供了全面的技术支持,包括工匠迁移等。

It uses capsule and lazy loads the components when they are used.

它在使用时使用胶囊和延迟加载组件。

Disclosure: I'm the author of this repository

披露:我是这个存储库的作者