I'm working on a core project A that use EasyAdminBundle. This project is use as a dependency in another project B. I'm looking for a solution to override a part of project A EasyAdmin configuration in project B.
I tried to create same files with same path in project B:
Project B: /config/packages/admin/my-file.yaml
Project A: /vendor/path/project-A/config/packages/admin/my-file.yaml
but it still use project A configuration file.
The goal is to override configuration of an entity edit form.
look at the overriding doc, the path renaming is only possible for files that are in the resource folder.
For overriding a service (or in your case a configuration) you should use service decoration and you won't need to rewrite the whole configuration but just the parameter that you need to change.
Related
I do not have access do composer or any command line tool on the environment, so I'm doing it manually.
Problem is: I didn't find any route to the translation file I want do use (mynewBundle/resources/translation/messages.pt.xlf) and it's using the translation file of the original bundle I used as reference (oldBundle/resources/translation/messages.pt.xlf).
Where can I change this setting?
Thanks.
Symfony will collect translations from various sources by default:
app/Resources/translations/
app/Resources/<BundleName>/translations
inside the bundle: Resources/translations
Symfony will load translations in priority from these folders, so you can overwrite the translations inside a bundle by putting the new ones into app/Resources/<BundleName>/translations. If you have both, the old and new bundle, still inside your project than it could very well be that the old translations have a higher priority by means how the bundles are loaded.
If you can't remove the old bundle then you best chance is, to place the new translations into app/Resources/MyNewBundle/translations/messages.pt.xlf, instead of leaving them inside the bundle.
I have a new symfony project. By default it contains
-/AppBundle
-AppBundle.php
--/Controller
--/Default Controller
Since I am going to have more bundles I would like it to be under a VendorName called MyProject where I have my ApiBundle.
I have tried moving AppBundle manually, then changing namespaces in the files, yml files and AppKernel. But I still get an error
Expected to find class "AppBundle\AppBundle" in file "/Applications/MAMP/htdocs/healthy-living/src/HealthyLiving/AppBundle/AppBundle.php" while importing services from resource "../../src/HealthyLiving/AppBundle/*", but it was not found! Check the namespace prefix used with the resource.' in /Applications/MAMP/htdocs/healthy-living/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php:133
Is there any console commands for doing this, if not what should be the procedures of moving it.
Thanks in advance
There's no console command or procedure to do it because it's not what vendor folder was designed for. vendor folder is meant to store 3rd-party code so keeping your own bundles, which you are developing, in vendor is not a good idea.
Since I am going to have more bundles
There is no reason that you can't keep more than one bundle inside your src folder. In fact, when Symfony introduced Bundle system it was very common that src folder contained a lot of bundles.
(note that vendor folder is almost always added to .gitignore - that's because what I wrote before)
EDIT after clarifying what the question is about:
It looks like command to generate bundles has/had some issues with creating bundles without Vendor folder:
Issue
Pull request
I don't know which version of Symfony are you using but either way creating bundle manually is always a good idea and it solves your problem too. (you can create it without vendor name)
You can upload your API bundle to a repository (Github, Gitlab, Bitbucket, etc.) and then import it as an external dependency with Composer.
Since moving was too complicated because of the config files that has to be changed so I decided to do a workaround and remove it and then install via console under the same parent. Works like a charm. Althoug could be a method in cli for this.
I'm working on a complex Symfony project. In the project, we have a core bundle which uses the parameters.yml located in app/config.
Each other AppBundle will inherit this CoreBundle and will correspond to a website.
What I need is to have specific parameters in each bundle that will override the default parameters one: when I'll use a route that will bring me into a controller's bundle, the parameters of this specific bundle have to override all the other ones.
I've tried the preprend method but it doesn't fit to this need. It only allows me to create new parameters for this bundle, but not to override the other ones.
I think you misunderstand the idea of bundles in Symfony. Bundle by design should be a reusable module, therefore the configuration placed inside a bundle is the default one. Then it is possible to override parameters (and not only!) in configuration in app folder.
The basic idea is:
Bundles don't use application. Application uses bundles.
So it's completely the opposite to what you expect it to be. Acutally it makes no sense to condition whole application configuration depending on current route since bundles can use one another. What if your currenct action will internally (without redirect) call another bundle's service or even controller?
Also it's worth mentioning that the app folder is the final folder for your application, therefore you can override in it not only bundle's configuration but also other things like services, view templates and so on.
Edit: I forgot to suggest a solution for you :)
Since you want to use custom parameters inside bundle, why do you need the default value in first place? Just create separate parameter namespace for each bundle that won't be overridden by application config. Then use it only inside that bundle.
Solution found thanks to dragoste's asking about separated kernels.
To solve my problem, I had to split the kernels : one for each website.
Documentation can be found here :
http://jolicode.com/blog/multiple-applications-with-symfony2
Is there a config file in Symfony 1.4 where you can place custom values that is accessible to your models? I was using app.yml in my frontend app so far but models are common for all applications in the project, so this won't work at the model level.
Create an app.yml file in the main project config/ folder - symfony will be able to use any values defined in it in the standard way. Just make sure the names don't conflict with anything in the app.yml files for each actual app.
In ZF you create a project by running this command:
zf create project MyProjectName
But how does one load a project that already exists?
I don't see anything in the documentation that specifies a zf load project or zf set project or something like that.
Thanks.
This is not yet possible to my knowledge, but on the to-do list
See http://framework.zend.com/issues/browse/ZF-7940
You can simply create another zf project in a different directory and copy the xml file into the the folder where it's missing. in the xml file, everything is relative, so you don't have to worry about the newly dummy project's path and others.