Can I use Laravel components in a WordPress plugin?

I need to write a pretty sophisticated plugin for WordPress, and I would like to use the components of the Laravel framework for a lot of grunt work. Can I use Laravel components without using the entire Laravel structure?

I am particularly interested in using its ORM.

+7
source share
2 answers

Yes, you can. because

Laravel 4 uses Composer to manage dependencies as the structure itself depends on the number of external packages to work properly. Each of the components used by Laravel 4 is individually available on the Illuminate GitHub Repository. Laravel 4 links Light components to create a frame.

So, for example, if you want to use the Illuminate Database component, you need to create a new instance of the "Capsule" manager. The capsule aims to simplify the configuration of the library for use outside the Laravel framework.

use Illuminate\Database\Capsule\Manager as Capsule; $capsule = new Capsule; $capsule->addConnection([ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'password' => 'password', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ]); 

Once the Capsule instance has been registered. You can use it like this: (Using the query builder)

 $users = Capsule::table('users')->where('votes', '>', 100)->get(); 

For a complete list of components, click here . You can also find information about the component on the Laravel website .

Update: Also make sure you have this on your server, because it requires Laravel-4 .

 PHP >= 5.3.7 MCrypt PHP Extension 

You can also take a look at Symfony Components , Laravel itself uses these components in its core components.

+9
source

The framework code for laravel is available at https://github.com/laravel/framework . Taylor made each laravel component available for use at https://github.com/illuminate . Therefore, if you are eloquent, look at https://github.com/illuminate/database . Readme has instructions for use.

In addition, here is a link to a tutorial for Slim Framework that implemented the eloquent as a standalone package: http://www.slimframework.com/news/slim-and-laravel-eloquent-orm

+2
source

All Articles