Symfony2 never updated routing file automatically when generating crud - symfony

Why every single time I generate a curd for some entity , every thing works right except for last action which is updating routing file. I always get this :
Generating the CRUD code: OK Confirm automatic update of the Routing
[yes]? Importing the CRUD routes: FAILED
The command was not able to configure everything automatically.
You must do the following changes manually.
Import the bundle's routing resource in the bundle routing file ....
I know that I can do it manually as the message suggests but I want to understand why it Fails ?

Related

Is there a way to access Doctrine repositories from stand-alone code?

I have a Symfony 4 app which is complete and working. Any uploaded files are put inside an upload folder outside the doc root and accessed via a separate cdn url.
Inside the upload folder I have a htaccess file that redirects any request, let’s say for example an image, to a php file which then serves the image.
What I want to be able to do is send an auth key along with the image request so that the standalone index.php file can check the user is valid from the database.
This means I need some way of accessing the symfony entity manager from outside of symfony, by including it. The other option would be a curl request to a symfony controller, but I’d rather not add additional network requests if possible. The third option is a separate pdo direct to the database and make sql queries... but again I’d prefer to use the symfony entity manager by including symfony somehow so I can use other features if needed.
I actually tried including the symfony bootstrap in the index.php but that then drags in the need for routing to work which isn’t needed in this case.
You can access EntityManager like that:
require __DIR__.'/../vendor/autoload.php';
(new Dotenv())->load(__DIR__.'/../.env');
$kernel = new Kernel('dev', true);
$kernel->boot();
$user = $kernel->getContainer()->get('doctrine.orm.entity_manager')->getRepository(Repo::class)->find(id);
dd($user->getRoles());

Symfony Update routes created with Loader

I have created a route Loader that creates concrete routes that points to controller. This concrete routes are based on entities so if I create or update an entity the corresponding routes needs to be created or updated. Until now the only way of doing this is using cache:clear command but I want to avoid this in production environment. I would like to just refresh the routes collection but I'm not sure if it's possible.

Demandware - Pipeline not found for current domain

I already made pipeline. Which is working fine. Suddenly it give error like
2015-12-18 02:39:08.091 GMT] ERROR system.core ISH-CORE-2368 Sites-SiteGenesis-Site core Storefront [uuid] [request-id]-0-00 [timestamp] "Error executing pipeline: Hello com.demandware.beehive.core.capi.pipeline.PipelineExecutionException:Pipeline not found (Hello) for current domain (Sites-SiteGenesis-Site)"
Does anybody know how to solve this?
In the event that your pipeline can not be found for the selected domain, please go trough and verify all of the following:
Double check Pipeline-Node naming
Pipeline URLs are generated by their name and your desired entry node, in this scenario, I would expect a file named Hello.xml in you cartridge's pipeline directory, and a start node named Start, would be accessed via {instanceURL}/on/demandware.store/Sites-mySite-Site/Hello-Start
Try and force upload of your cartridges
Occasionally the files on the server will not be updated correctly when a save is made; to force an update, right click your project, click Demandware > Upload Cartridges
Check your Cartridge Path
If you are using a shared instance, or your instance is re-provisioned, you may need to check your cartridge path to be sure your custom cartridge(s) are still there.
Check your Code Versions
Occasionally you may increment / change your code version - if you do, make sure that the path you select in Studio is the one that you have selected in Business Manager.
Tech Support
Should you still have issues following the four steps above, please file a support ticket and the tech-support team will be able to provide you with more assistance.

Is it possible to pass a route parameter to a configuration loader in Symfony?

I have an application that requires some per-tenant configuration. What I would like to do is load configuration for specific bundles using parameters embedded in the route:
Route: /{tenantId}/some/resource/390234
where I can then load a configuration specific to $tenantId.
As far as I know this is not possible, since configuration loading in symfony2 happens on compile time.
This means every time you do a
php app/console cache:clear
or cache warmup.
Why not do this via configuration entries via database? As an alternative, use a custom class to load e.g. yaml files (don't forget caching) with your own configuration.

Detect routes and entities from Symfony2 vendor

i'm creating a bundle that adds an entity and a few routes to be use in a Symfony2 application.
I want my bundle to be used as a vendor, so I've created all the files, published it on GitHub and packagist and everything works fine.
My problem is now when I require the bundle in another project, my entities and my routes are not detected:
1) php app/console doctrine:schema:update doesn't detect any modification
2) When I try to hit a GET route from the vendor, here is the error I get:
No route found for "GET ..."
Any idea is welcome, what's the process to really do these things in a bundle?
Cheers.
Cyril
Take a look at the installation steps of the FOSUserBundle for example. Everyone who uses your published bundle, have to activate it in the appkernel and import the routes. For the entity I think the bundle user have also to subclass the entity.

Resources