Symfony bundle - generate configuration file - symfony

I'm working on creating a Symfony bundle, so far so good, but I'm running into a problem when I want to generate a configuration/route file when installing the bundle. When I install the bundle I would like it to generate the configuration files in the app and not have to add them by hand.
Could someone help me please?
I tried to load yaml / xml files within my Extension file, I tried to import via services.xml but I can't make it working.
Thank you ! :)

Related

How to add Bootstrap to my Symfony 4.1 project?

I tried to find a similar case to mine but didn't succeed.
Here is the issue. I followed Symfony documentation to add Bootstrap to my project.
I indeed get a bootstrap folder in a new folder called "nodes_modules".
The thing is i can't find a global.scss file anywhere (as mentioned in the tutorial) then i don't know where to put the following command:
#import "~bootstrap/scss/bootstrap";
Do i have to create this file or does it exist somewhere in my Symfony project?
Thank you in advance.
Yes, global is your application scss file, it can be named different on you wish. You can refer this documentation in order to see how to configure it (it is app.scss in the example)
I understood what was wrong there! So if you are creating a Symfony 4.1 project on mac and you don't know where to import your bootstrap theme(s) since you don't have any assets folder here is the solution:
To have the assets folder you have to install the webpack "encore".
Please make sure you have node.js and yarn installed before that.
Then just run the following commands inside your root project directory:
composer require symfony/webpack-encore-pack
yarn install
You might have now an "assets" folder inside your project with an assets/css/app.css file and a assets/js/app.js file.
Thank you for your time ScayTrase.

Where is API Platform config for entity mapping is situated in the latest versions?

The documentation says that there is file api/config/api_platform/resources.yaml where I can map entities using yml. But neither in the distribution nor when I install API-platform as a package I can't find this file. Creation of the directory and file manually doesn't help.
In the context of a Symfony 4 project, the file can be located at config/api_platform/resources.yaml. If it doesn't exist, simply create it.
You can also use several files in order to define your mappings:
config/api_platform/resources/entity1.yaml
config/api_platform/resources/entity2.yaml
I suggest to use separate files since it's simpler to maintain than one big file.
You'll have to configure these paths in the config/packages/api_platform.yaml file:
api_platform:
mapping:
paths: ['%kernel.project_dir%/config/api_platform/resources']
See Nek's answer for a complete example.
I find the documentation a little bit confusing about this, because in a Symfony project there's no api/ directory at the root of the project.

Including a file in WEB-INF/lib

I am porting AXIS 2 SOAP webservice to an existing grails 2.4.4 project.
It works flawlessly when run from the IDE but not fram a WAR.
I have tracked this down to addresing.mar NOT being copied to the WEB-INF lib directory. If I copy this file myself then ever thing works fine.
We are using Jenkins for CI and using the Grails plugin to do the compilation of and packaging of the WAR file.
This does not include the addresing.mar file. Also when running the Grails war command it is not included.
I have tried many way to get this to be included. The AXIS plug in just wrecks the compile to teh extent that it is unusable.
I have just spent 2 days googling and tried ever thing I can find in just about every combination.
We are now getting to the point we we are considering post processing the war file and adding the addresing.mar file directly.
Though that will work it would not help my understanding of what I am doing wrong!
Any help most appreciated.
Try saving your file inside the /src file. Grails autowires external libraries when saved inside this folder.
Note: This is only applicable to Grails versions running less than 3.x.x
I don't know too much about AXIS 2 SOAP and the mentioned addressing.mar file but if it's available in the project while building the war file you could use the grails.war.resources parameter in BuildConfig.groovy and simply copy it into the lib directory in the following way:
grails.war.resources = { stagingDir, args ->
copy(file: "path/to/addressing.mar", todir: "${stagingDir}/WEB-INF/lib/")
}
more info about grails.war.resources in the manual

Symfony don't generate new bundle

I try to generate bundle in Symfony 2, using command line tool.
After running bundle:generate command, there is no generated bundle in /src folder.
Watch this short video to see a problem: https://www.youtube.com/watch?v=9zKgaqWz8rs
There is no any errors in console.
i think you're in the wrong directory.
you look at Computer/F:/symfony/src and the composer told you it generated a bundle in F:/xampp/htdocs/symfony/src.
so take a look in F:/xampp/htdocs/symfony/src, it might be there.

Installing Capistrano with a specific config dir

I have a Symfony2 application that I would like to deploy using Capistrano3. Performing cap install creates a config directory in the projectroot. To keep my project clean, I would like it to install the config dir into something like app\config\capistrano. Is this possible? I cannot find any hints in the documentations.
Found the anwser in a pull request on Github.
Enter the following two lines to your Capfile, before capistrano\setup beign called.
set :deploy_config_path, 'app/config/deploy.rb'
set :stage_config_path, 'app/config/deploy'
`
It is implemented in the 3.1.x branch
Look at your Capfile and change the path to the config file. This should be enough.

Resources