Hi,
The problem i have in my Symfony 6 project happens when my routes have more than one "/" like so :#[Route('/user/{id}', name: 'edit_user')]
This prevents any of my assets from loading correctly. I got a vague understanding of how Metronic loads these in my pages by checking master.html.twig, ThemeHelper.php and services.yaml but i cannot think of a practical way to solve this.
Hi,
Sorry for the delay. The assets load from this file /starterkit/src/Service/ThemeHelper.php in function function asset. We will fix it as soon as possible and provide you fix as workaround soon.
Thanks
We have fixed the issue with loading assets in your Symfony project.
To fix this, we have used Asset Component.
https://symfony.com/doc/current/components/asset.html
We installed it with Composer by running the following command:
composer require symfony/asset
use Symfony\Component\Asset\Package;
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
$filesystem = new Filesystem();
if (!$filesystem->exists("/public/assets/manifest.json")) {
return $this->package->getUrl(sprintf("/assets/%s", $path));
}
Hi,
$package was not recognized so i generated a class instance before calling it. It seems to work just fine, let me know if you are dealing with this error in a different / more optimized way.
$filesystem = new Filesystem();
if (!$filesystem->exists("/public/assets/manifest.json")) {
$this->package = new Package(new EmptyVersionStrategy());
return $this->package->getUrl(sprintf("/assets/%s", $path));
}
Thank you very much.
Hi,
Yes, the class need to be initialized. We put it in the _construct function.
public function __construct(CacheInterface $cache)
{
$this->cache = $cache;
$this->package = new Package(new EmptyVersionStrategy());
}
Thanks