bin/blade-linter
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Bdelespierre\LaravelBladeLinter\BladeLinterCommand;
use Illuminate\Config\Repository as Config;
use Illuminate\Filesystem\FilesystemServiceProvider;
use Illuminate\Support\Facades\Facade;
use Illuminate\View\ViewServiceProvider;
use Symfony\Component\Console\Application;
// create an empty application
$basePath = '.';
$app = new \Illuminate\Foundation\Application($basePath);
$app->useAppPath($basePath);
$app['config'] = fn() => new Config([
// use current directory as view path
'view.paths' => [ $basePath ],
// send compiled views to /tmp
'view.compiled' => sys_get_temp_dir(),
]);
// register services
(new FilesystemServiceProvider($app))->register();
(new ViewServiceProvider($app))->register();
// set the container so the Config::get calls resolve
Facade::setFacadeApplication($app);
// prepare the command
$command = new BladeLinterCommand();
$command->setLaravel($app);
$command->setName('lint');
// create the Symfony console application
$application = new Application();
$application->add($command);
$application->run();