Symfony's framework.ide config for PhpStorm and Vagrant - symfony

How do I set up framework.ide config value so that it properly links to files in PhpStorm, when the code is run from Vagrant?
I've tried phpstorm://open?file=%%f&line=%%l
but it gives me Vagrant paths, like:
phpstorm://open?file=/vagrant/src/AppBundle/Controller/DefaultController.php&line=27
while I should be getting host paths, like:
phpstorm://open?file=/Volumes/my_project_volume/project_name/src/AppBundle/Controller/DefaultController.php&line=27
I guess the solution would be to somehow configure path mapping, either in Symfony or in PhpStorm.

Regarding symfony's official documentation:
https://symfony.com/doc/current/reference/configuration/framework.html#ide
you can use (from symfony 3.2) something like this:
ide: 'phpstorm://open?file=%%f&line=%%l&/path/on/vagrant>/your/local/path/'

For a project relative directory:
framework:
ide: 'phpstorm://open?url=file://%%f&line=%%l&/path/in/server>%kernel.project_dir%'

When working with Docker and with Mac, and your project is hosted in your user folder, the configuration has to slightly get changed as well.
framework:
ide: 'phpstorm://open?file=%%f&line=%%l&/app/>/Users/your-username/PhpstormProjects/your-project-folder/'
Please note that
/app/ is the path inside the Docker container,
using ~/PhpstormProjects as alias to the home directory is something PHPStorm does not seem to support

Related

PhpStorm doesn't get the folder's configuration when running a single test method

I have a Laravel project with three test directories - Browser, Feature, and Unit.
In Run/Debug configurations I've configured the Feature and the Unit directories to use phpunit.xml while the Browser directory uses phpunit.e2e.xml. I've also created a default configuration for all tests which uses the phpunit.xml.
If I open a class that is in the Feature/Unit directories and run a single test method or the whole class, it picks the default configuration, but when I run a single test method in the Browser directory, it uses phpunit.xml instead of phpunit.e2e.xml.
If I select a directory and run tests, it picks the proper configuration, but when I open a class in the Browser directory, it doesn't
Why doesn't PhpStorm use the configuration of the Browser directory recursively? How can I handle this problem?
As far as I know PhpStorm has never had this functionality and I wouldn't count on them adding it either. It seems way too specific.
What you can do though, is specify the configuration file you want to use through the commandline.
See: https://phpunit.de/manual/6.5/en/textui.html#textui.clioptions
So your command would look something like this:
phpunit tests\Unit\SomeTest.php --configuration phpunit.xml
or
phpunit tests\Browser\SomeTest.php --configuration phpunit.e2e.xml

Consul template is not restarting nginx windows

I am using consul template v0.19.0 for windows, for rendering nginx config.
The nginx config Is rendering fine by the consul template but It is not restarting the nginx.
This is the command I am using.
Consul- template -consul-address="xx" - template="in:out:{{pathfornginx}}\nginx.exe -s reload" .
Where "in" is the ctmpl path and "out" is the final nginx config path..
I have tried with different path format but no luck.
Could anyone drop some input on this.
Thx in advance.
Did you tried to create a config.json file which will contain the path to the ctmpl file, and the command itself?
You would need to use the -config flag instead of -template
If you want an example for the config.json I can provide you one.. I'm using similar setup and it works fine for me
Provide me a better solution?

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

Docker and bower links

I'm using docker to run a simple static web project, using the nginx official image. As a bower dependence I have a ui lib that is mine and is shared among two of my projects. To facilitate the development process I created a volume to my local machine to serve local files through the /html folder inside the nginx container. It works fine this way.
But, if I try to use bower link to create a link between a local copy of my ui lib and the bower dependence the nginx web server is not able to find the folder, since the link points to my local machine.
I'm running the docker vm in a Mac.
Did someone experienced something similar and have an idea about how to solve it?
Thanks,
I just run into this issue and found a way to solve it nicely.
The problem is that when you mount as a volume the whole /html folder the symlinks created by bower link are copied into your container but not the actual folders they are pointing at. When nginx tries to serve the file, it follows the symlink but now INSIDE the container, where the route is invalid.
To fix this, create another volume that maps the symlink directly. This way, docker-compose will follow the symlink BEFORE mounting into the container, therefore copying the actual folder contents. The nice thing about this is that in your local file system you still have the folder and the symlink working, so you can work as usually :)
Practical example:
My folder structure
/app
|--/bower_components
|--/packageA
|--/packageB -> symlink to /foo/bar/packageB
My compose file:
version: '2'
services:
nginx:
volumes:
- .:/foo
- ./bower_components/packageB:/foo/bower_components/packageB
...
Let me know if it worked, cheers!

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