Depraction warning loading file assets from src is deprecated - symfony

I have stuff like #import '../assets/scss/WebsiteBundle/font.scss'; in scss/WebsiteBundle/default.scss, however, since Symfony 4.4 I get the following depracitation warning.
Loading the file "../assets/../_photo.scss" from the global resource directory ".../src" is deprecated since Symfony 4.4 and will be removed in 5.0.
I can't seem to find anything in the documentation about this. Can someone help me?

In the routes.yaml file, make sure that you have all your routes with the directive type, this fixed this bug for me.
Example as it follows:
api:
prefix: /api
resource: '../src/Controller/Api'
type: annotation

I fixed this by using
$configDirectories = [__DIR__ . '/../../templates'];
$fileLocator = new FileLocator($configDirectories);
$fileName = $fileLocator->locate($resource, null, true);

Related

Standalone doctrine annotation routing - cannot load resource

I have a routes.yml file
controllers:
resource: ../src/Controller/
type: annotation
I am trying to load it
$loader = require __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader([$loader, 'loadClass']);
$locator = new FileLocator([__DIR__.'/../config']);
$loader = new YamlFileLoader($locator);
$routeCollection = new RouteCollection();
$importedRoutes = $loader->load("routes.yml");
And I get
Cannot load resource "../src/Controller/". Make sure annotations are installed and enabled.
I have tried variations, with and without quotes, backslashes, forward slashes...
"../src/Controller/"
"../src/Controller/API.php"
I have both doctrine/annotations and sensio/framework-extra-bundle installed
A similar issue came up in the Symfony Github issues, but I seem to have done what the solution is, according to Fabien Potencier.
To clarify, I am not using the complete Symfony package, but trying to use individual components to build the routing. Any ideas why I am getting this error message?

sf2 : Unknown "asset" function in "#Twig/Exception/exception_full.html.twig" at line 4

I'm using Symfony 3.1
I have this error when I run app_dev.php :
Unknown "asset" function in "#Twig/Exception/exception_full.html.twig"
at line 4.
I already checked my config.yml, and it contains these values :
framework:
assets:
base_path: ~
...
I don't know what to do... I hope someone can help me. Thank you !
EDIT : Problem solved. I had to remove custom twig filters in my config.yml... :)
Try to set:
assets: ~
Issue about same problem
https://github.com/symfony/symfony/issues/17291
Edit:
Please also check that`s symfony assets component was installed.
The symfony/asset component is required, even in 3.0, by the FrameworkBundle
As you can see:
https://github.com/symfony/framework-bundle/blob/master/composer.json
Another way run update symfony to latest version and update all depend

Relative directory loading in routing.yml without bundle reference

I'm trying to use Symfony2 without bundles. When my routing.yml looks like this:
app:
resource: "/var/www/oo_talks/src/UI"
type: annotation
Everything works in browser. But how do I get rid of full path here if I do not use bundles? How can I reference root project folder?
And still, running console command gives error about being unable to load a resource.
Added later, based on comments:
resource: "%kernel.root_dir%/src/UI" doesn't work as well as resource: "%kernel.root_dir%/../src/UI". Still "Cannot load resource" error.
Adding parameter with full path and referencing it doesn't work either.
By default relative path is resolved by file_locator service relatively to the %kernel.root_dir%/Resources directory or relatively to the directory of the file where path was specified.

Symfony2 - integration of ckeditor and sonata media bundle

I am trying to integarte IvoryCKEditor with sonata media bundle. Perpose is to allow image uploads in ckeditor. I tried it using a CoopTilleulsCKEditorSonataMediaBundle but i keep getting an error:
An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "admin_sonata_media_media_ckeditor_browser" as such route does not exist.") in "IvoryCKEditorBundle:Form:ckeditor_widget.html.twig".
Thanks :)
You should check your routes with the command:
$ php app/console debug:router | grep ckeditor
Then you have to replace admin_sonata_media_media_ckeditor_browser and admin_sonata_media_media_ckeditor_upload by routes founded with this command, in the config of ivory_ck_editor (maybe in your config.yml or your ivory_ckeditor.yml file)
If you don't have route for ckeditor, I think you should check if you install correctly the bundle.
1) install SonataFormatterBundle 2) add the bundle and its dependencies in AppKernel 3) config files 4) CLEAR CACHE 5) roll
Reason of the issue
This problem arises when trying to integrate CKEditor through the
SonataFormatterBundle without using the SonataAdminBundle.
In fact, the integration proposed by the SonataFormatterBundle is meant to only work for the SonataAdminBundle, and no easy integration for a custom admin bundle is currently available.
Note that this dependency is not specified in the documentation at the moment.
How to solve the problem
Simply install the SonataAdminBundle following this installation process. You do need to configure the bundle entirely as specified in the documentation. To add the routes that were missing, such as admin_sonata_media_media_ckeditor_browser, simply add the following to your config/routes.yml:
# This is your custom admin bundle
admin:
resource: "#AdminBundle/Controller/"
type: annotation
prefix: /admin/
# Import SonataAdminBundle routes
admin_area:
resource: "#SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
prefix: /admin/sonata # put whatever prefix here
_sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
Just to add something.
If you are SURE that you have installed, all dependencies, and set all configs correctly, and still getting this error, then the cause may be that you have defined your 'sonata_media' prefix in routing.yml differently.
You can check all urls in your project in:
app/cache/dev/appDevUrlGenerator.php
In there you will find ALL routes in a variable $declaredRoutes
Afterwards simply put correct route name for browsing.
It will not work without SonataMediaBundle - you will need to install it with SonataFormatterBundle
Sonata become too complicated as for me, so I just use IvoryCKEditorBundle directly

Symfony 2: LiipDoctrineCacheBundle not found in AppKernel

I've installed this bundle LiipDoctrineCacheBundle in vendor\bundles\ folder of my website.
Then, as usual, I added in autoload.php a new entry in the array namespace:
'Liip' => __DIR__.'/../vendor/bundles',
And I registered this new bundle in the bundles' array of AppKernel.php:
new Liip\DoctrineCacheBundle\LiipDoctrineCacheBundle(),
But weirdly I get this error message:
Fatal error: Class 'liip\DoctrineCacheBundle\LiipDoctrineCacheBundle' not found in C:\workspace\LHN\app\AppKernel.php on line 26
It's like if Symfony cannot retrieve the bundle in the nameSpace...
So I've tried by changing the case of the bundle key: 'Liip'==> 'liip'
And I've also tried with the fully path location:
__DIR__.'/../vendor/bundles' ==> C:\workspace\mySite\vendor\bundles
Any idea?
Thks
Symfony: 2.0.9
Liip bundle: master
You are probably using the wrong name for the bundle class.
i think it should be
new Liip\LiipDoctrineCacheBundle\LiipDoctrineCacheBundle()
or
new liip\LiipDoctrineCacheBundle\LiipDoctrineCacheBundle()
not sure if the first "L" is capital or not in your vendor/bundles/ source
Thanks to Laurynas's comment I understood my problem: the source bundle path was wrong
vendor\bundles\liip\LiipDoctrineCacheBundle
instead of
vendor\bundles\Liip\DoctrineCacheBundle
The origin of this issue is that I made a mistake in the deps file (where the git location, the version and the target directory are defined) by setting the target property to /bundles/liip/LiipDoctrineCacheBundle instead of to /bundles/Liip/DoctrineCacheBundle.
My bad... ;-)
Correct dep block:
[LiipDoctrineCacheBundle]
git=https://github.com/liip/LiipDoctrineCacheBundle.git
target=/bundles/Liip/DoctrineCacheBundle
version=master

Resources