1

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: https://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.

2 Answers 2

1

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

composer require illuminate/database

Basic usage

Create database connection


use Illuminate\Database\Capsule\Manager 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 Illuminate\Database\Capsule\Manager 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.

0

You may use illuminate/database

1
  • 1
    This is a low quality answer. Link only answers are frowned upon here. Can you address the OPs question in your answer?
    – closetnoc
    Jan 22, 2018 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.