Mobile app version of vmapp.org
Login or Join
Welton855

: Can I use the Laravel Database Framework without using all of Laravel? I work at a company with a custom PHP framework we have built over the years. For the most our custom framework suits

@Welton855

Posted in: #Database #Laravel #Mysql #Php #Phpmyadmin

I work at a company with a custom PHP framework we have built over the years. For the most our custom framework suits our needs and includes almost everything Laravel offers, however, our database classes are outdated and we need to update them. Rather than rebuilding our our database classes we've been looking at some pre-built options.

So far the database classes within Laravel seems to be the most attractive. However we don't need/want the entire Laravel framework, we pride ourselves on having a very slimmed down base/framework that we built and adding the entire Laravel library seems like overkill when we just want the Database functionality. So long story short is the a way to easily extract just the Database Library within the Laravel Framework to run stand alone so we can integrate it into our customer framework. So far I haven't found very many options.

The best option I have found so far is below: github.com/Luracast/Laravel-Database
However that GIT Repository hasn't been updated in over 2 years.

I've also looked into Lumen, but even the slimmed down version of Laravel seems like to much extra code that we don't need.

Does anyone know of any ways of integrating just the Laravel Database classes into our framework.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Welton855

2 Comments

Sorted by latest first Latest Oldest Best

 

@Margaret670

You may use illuminate/database by requiring it in your composer project.

composer require illuminate/database


Basic usage

Create database connection



use IlluminateDatabaseCapsuleManager as Capsule;

$capsule = new Capsule;

$capsule->addConnection([
'driver' => 'mysql',
'host' => 'mysql.domain.com',
'database' => 'database',
'username' => 'mysql_rw',
'password' => 'pass',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);



$capsule->setAsGlobal();


Create database table(s)



use IlluminateDatabaseCapsuleManager as Capsule;

$schema = Capsule::schema();

$schema->create('table_name', function ($table) {
$table->increments('id');
$table->string('name')->length(10)->default('Nick');
});


If you need any further documentation, you can look it up by visiting the Laravel docs here.

10% popularity Vote Up Vote Down


 

@Gonzalez347

You may use illuminate/database

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme