How to add a new Page to Akeneo 5.0 with a Symfony-Bundle? - symfony

I have a registered and working bundle in Akeneo 5.0 with Symfony 4.25.
My Bundle works and does as expected however i try too add a empty page to akeneo which does not work.
This Tutorial was my starting point but since in version 5.0 it is not avaible i cant be sure this works.
I used the tutorial too create following structure in my bundle:
file structure
with contents matching such as in the tutorial is given. Only difference is that in routing.yml a controller definition is mandatory so i implemented a simple class for that.
However if i run stated commands from tutorial:
$ bin/console --env=prod pim:installer:assets --symlink --clean
$ yarn run less
$ yarn run webpack
i can reach my desired route but the template is not loaded. The Page shows my defined template (which only says Hi $name) without any of the default-templatew

Related

Symfony 4.4 - Custom Error Templates Not Working

I've got an issue when it comes to using Custom Error Templates in Symfony 4.4 Flex. Everything has been set properly according to the guide from https://symfony.com/doc/4.4/controller/error_pages.html
I can access the Custom Error Templates via /_error/{errorCode} when I run the application with APP_ENV=dev - but if I change APP_ENV to prod (with APP_DEBUG set to false/0 of course), I get the default Symfony "500 Internal Server Error" page. I even tested it after deploying the application on the remote host, and it's the same issue when I try to access /random-unexisting-page (already got the error404.html.twig template set and it works on 'dev' via /_error/404).
I want to know, does it have anything to do with other configuration within /config/ ? Have you got any idea what the issue could be ?
I made a few tries and I think I've understood your problem.
So when you want to create a personalized error page, first you need to add, under the template directory, the following path, same as your link said
templates/
└─ bundles/
└─ TwigBundle/
└─ Exception/
├─ error404.html.twig
├─ error403.html.twig
└─ error.html.twig # All other HTML errors (including 500)
The most common error is the 500 so you can add this: error500.html.twig or just leave the generic one, it's up to you.
The importamt thing is that whenever you add a file error in the directory or you simply make a change in an existing file: you MUST launch the command to clear the cache (you can only launch this command when the project has no errors). If you don’t do this the changes wont be visualized.
STEPS:
fix the error or start from a previous working build
launch the clear command: php bin\console cache:clear,
you'll get something like that result_of_clear_cache
refresh the page and you should see the new page
PS. if you need some visual references:
path
error_file
result_on_browser

setting symfony for local development on herkou

I am trying to set up my symfony 2.8 app for local development.(Following - https://symfony.com/doc/current/deployment/heroku.html)
Added In proc file
web: bin/heroku-php-apache2 web/
Error
bin/sh: vendor/bin/heroku-php-apache2: No such file or directory
Also note , composer.phar config bin-dir is bin
Anyone who can share how they resolved this problem?
First of all, have you tried letting heroku create the Procfile itself? I think lately it was smart enough to work out the root of the Symfony project.
If that doesn't work, maybe that's not the right path, try:
echo 'web: $(composer config bin-dir)/heroku-php-apache2 web/' > Procfile
If none of those work, I'd rather use the heroku information on how to deploy your Symfony app, have a look at this and see if it helps:
https://devcenter.heroku.com/articles/getting-started-with-symfony

Variable "app" does not exist with Twig

I'm trying to get the URL of my page with Twig.
So I wrote this in my index.html.twig:
{{ app.request.attributes.get("_route") }}
I'm getting this Symfony exception:
Variable "app" does not in exist in "AcmeFoo..."
I had the same problem and sometimes in addition to clearing the cache, it was necessary to rebuild the bootstrap cache. I created a little shell script (cache.sh) like this:
#!/bin/bash
cd /yoursymfonyrootfolder
php app/console cache:clear --env=prod
#path depends on symfony version
php ./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
Just place that file in your symfony root folder and execute it with ./cache.sh

Symfony2 - Target directory changed when generating a bundle

I've noticed this recently, from a clean install of Symfony2 and removed AcmeDemoBundle (from the AppKernel, routing_dev.yml etc.). I generate the bundle and noticed that the Target directory for the bundle has changed and every time I create a new bundle I have to manually put in the proper path to it. Seems to be a problem with the latest release of Symfony2.
Changed Target directory line during bundle creation:
Target directory [/var/www/html/Project/app/cache/dev/../src]:
The path that it use to point was:
Target directory [/var/www/html/Project/src]:
I am at a loss for what changed as I installed a clean build and did not alter any settings.
When I installed Symfony2 I used the following: (which is the same way I've used previously)
composer create-project symfony/framework-standard-edition Project #stable
php app/console generate:bundle (see last line)
Welcome to the Symfony2 bundle generator
Your application code must be written in bundles. This command helps
you generate them easily.
Each bundle is hosted under a namespace (like Acme/Bundle/BlogBundle).
The namespace should begin with a "vendor" name like your company name, your
project name, or your client name, followed by one or more optional category
sub-namespaces, and it should end with the bundle name itself
(which must have Bundle as a suffix).
See http://symfony.com/doc/current/cookbook/bundles/best_practices.html#index-1 for more
details on bundle naming conventions.
Use / instead of \ for the namespace delimiter to avoid any problem.
Bundle namespace: Foo/FooBundle
In your code, a bundle is often referenced by its name. It can be the
concatenation of all namespace parts but it's really up to you to come
up with a unique name (a good practice is to start with the vendor name).
Based on the namespace, we suggest FooFooBundle.
Bundle name [FooFooBundle]:
The bundle can be generated anywhere. The suggested default directory uses
the standard conventions.
Target directory [/var/www/html/Project/app/cache/dev/../src]:
Fixed by updating composer:
composer self-update
Then creating a new project.

Symfony2, How to load fixtures with --fixtures option?

I need an example for command below in Symfony2 :
php app/console doctrine:mongodb:fixtures:load --fixtures=/path/to/fixture
I don't know how to set the --fixtures=/path/to/fixture. I can load all together but I cannot do it for only one new fixture !
What format should /path/to/fixture be ?
Also I tried this --fixtures=src/PMI/UserBundle/DataFixtures/ORM/FeatureFixtures but I get this every time :
[InvalidArgumentException]
Could not find any fixtures to load in:
- src/PMI/UserBundle/DataFixtures/ORM/FeatureFixtures
I know this is old but other people have asked and these answers may not cover some of the other questions.
You only need to specify the folder, not the file. In the above question, its not clear if FeatureFixtures is the php file or actually a folder. It may be failing if that is only a php file and not a folder. This is the correct way to load the fixtures assuming that FeatureFixtures is a php file with the fixtures:
doctrine:fixtures:load --fixtures=src/PMI/UserBundle/DataFixtures/ORM --append
You can define a fixture with the real path.
php app/console doctrine:fixtures:load --fixtures=src/MyBundle/DataFixtures/ORM/LoadMyFixturesData.php
It's not require but if you want to manually specify the directory where the fixtures classes should be loaded you can use this :
for example if I execute a command in directory symfony
--fixtures=/src/yourBundle/fixture
Starting with DoctrineFixturesBundle version 3.1 you need to use doctrine:fixtures:load --group=FeatureFixtures.
For symfony +3 you can use this command:
php bin/console doctrine:fixtures:load --group=YourFixtures --append.
Or short version:
php bin/console d:f:l --group=YourFixtures --append.
where option:
--group Target fixture. If you do not use the option, then load all your fixtures;
--append Without this option the load fixture command will remove all data from your database. Use this option to add new data without removing old data.

Resources