PHP code example of laravel-bridge / scratch

1. Go to this page and download the library: Download laravel-bridge/scratch 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/ */

    

laravel-bridge / scratch example snippets


public function setupDatabaseConfig(string $name, array $connection, bool $default = false);

public function setupDatabaseConfig(array $connections, string $default = 'default');

use LaravelBridge\Scratch\Application;

$connections = [
    'driver' => 'sqlite',
    'database' => __DIR__ . '/sqlite.db',
];

$app = Application::getInstance()
    ->setupDatabaseConfig('default', $connections, true)
    ->bootstrap();

use Illuminate\Database\Eloquent\Model;

class User extends Model
{

}

// ---

$user = new User();
$user->username = 'root';
$user->password = 'password';

$user->save();

User::all()->toArray();

use LaravelBridge\Scratch\Application;

Application::getInstance()
    ->setupTranslator(__DIR__ . '/lang')
    ->setupView(__DIR__, __DIR__ . '/compiled')
    ->withFacades()
    ->bootstrap();

echo View::make('view', ['rows' => [1, 2, 3]]);

public function setupLogger(string $name, LoggerInterface $logger, bool $default = false);

$spy = new TestHandler();

$logger = new Monolog\Logger('test');
$logger->pushHandler($spy);

$this->target->setupLogger('test', $logger, true)
    ->bootstrap();

Log::info('log_test');

$this->assertTrue($spy->hasInfoRecords());

$app->withFacades();

View::make(); // It's works