1. Go to this page and download the library: Download phpdot/bun 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 PHPdot\Bun\Resources\AssetPipeline;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
final class Assets extends AbstractExtension
{
public function __construct(private readonly AssetPipeline $pipeline) {}
public function getFunctions(): array
{
return [
new TwigFunction('js', fn (string $entry): string => $this->pipeline->manifest()->js($entry)),
new TwigFunction('css', fn (string $entry): string => $this->pipeline->manifest()->css($entry)),
];
}
}
return [
'pinnedVersion' => '1.4.0', // never "latest"
'registryUrl' => 'https://registry.npmjs.org', // a mirror is this one setting
'resourcesDir' => dirname(__DIR__) . '/' . 'resources', // home is its derived .bun subdirectory
'outputDir' => dirname(__DIR__) . '/' . 'public/build',
'baseUrl' => null, // null → derived (/build); a path; or an https CDN base
];