1. Go to this page and download the library: Download litebase/litebase-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $connection = 'litebase';
protected $table = 'users';
}
// Use the model
$user = User::create([
'name' => 'John Doe',
'email' => '[email protected]',
]);
$users = User::where('active', true)->get();
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
protected $connection = 'litebase';
public function up()
{
Schema::connection('litebase')->create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->boolean('active')->default(true);
$table->timestamps();
});
}
public function down()
{
Schema::connection('litebase')->dropIfExists('users');
}
};
use Illuminate\Support\Facades\Schema;
// Check if table exists
if (Schema::connection('litebase')->hasTable('users')) {
// ...
}
// Get all tables
$tables = Schema::connection('litebase')->getTables();
// Get table columns
$columns = Schema::connection('litebase')->getColumns('users');