Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mulp's avatar
Level 1

Laravel and Jigsaw

Hi people,

I'm using Jigsaw to generate a Static Web Site. It uses laravel as underlying system.

I would also like to use the laravel db library to connect to a database and do something before the generation. I tried to register the Facade and using the DB from the listener class:

$container->when(['DB' => Illuminate\Support\Facades\DB::class]);
$container->bind(Illuminate\Support\Facades\DB::class);
Facade::setFacadeApplication($container);

but I got an error while I try to access the DB class:

In Container.php line 788:
                           
  Class db does not exist  

In this context I don't have any config.php to put my configuration, so I guess I need to do it manually.

Does anybody know how to do it?

Thanks in advance.

0 likes
4 replies
mulp's avatar
Level 1

@bobbybouwmann thanks for your reply.

I was able to installe the illuminate/database and manually add an alias to the DB class.

$container->alias(Illuminate\Support\Facades\DB::class, 'db');

But if I try to call the select method on it I got an error:

Uncaught Error: Call to undefined method Illuminate\Support\Facades\DB::select()

About the DatabaseServiceProvider how can I load it manually? I used the following:

$container->bind(DatabaseServiceProvider::class);

but not sure it's the right way. Keep in mind that the Jigsaw environment does not have any laraval config file, so I need to manually load anything I need.

Thank you so much

bobbybouwmann's avatar

You can't just register the service provider, so it seems. Instead, you can bind all classes yourself like shown in the DatabaseServiceProvider class itself.

Please or to participate in this conversation.