Viewed   146 times

I had problems with configuring PhpStorm IDE to use while working with Symfony 3.3.

I decided to just download phpunit.phar to bin and use it instead.

Symfony 3.4 (and Symfony 4), does not even have phpunit.xml.dist out of the box, so there is a problem with using phpunit.phar easily.

I've installed PHPUnit using flex:

composer req phpunit

That created phpunit.xml.dist and I was able to run tests from command line by:

php bin/phpunit

But again I could not make PhpStorm use it.

So I downloaded phpunit.phar and it can work together with provided phpunit.xml.dist.

Question 1: Is there any way for PhpStorm IDE to use phpunit-bridge?

Question 2: What is the best practice for Symfony 4 (phpunit-bridge or vanilla phpunit.phar)?



What I usually do is point my phpunit testing framework on PHPStorm to the secret .phpunit directory which was created by the bridge, like:

The location of the "phar" file is:


or in some cases:


After this, the specified phpunit executable will be called correctly when exeuting unit-tests, but with a --no-configuration option. This can cause autoloading problems (a lot of "class not found" errors), because the autoloader generated by Composer is not specified anywhere.

To fix this, you should have a phpunit.xml file in your project (this is common practice anyway), in which you specify Composer's autoloader, something like this:

<phpunit bootstrap="vendor/autoload.php">

This phpunit.xml should then be specified in the "Default configuration file" option and you should be good to go.

Regarding phpstorm using phpunit-bridge: It's possible as a custom script, but you won't have the nice interface and the possibility to run (and debug) specific tests via PHPStorm interface.

Monday, October 24, 2022


$formbuilder = $this->createFormBuilder()
        ->add('name', TextType::class, ['required' => true]])
        ->add('email', EmailType::class, ['equired' => true]]);

    $formbuilder->add('username', TextType::class, ['required' => true]])
         ->add('password', PasswordType::class, ['required' => true]]);

$form = $formbuilder->getForm();

if ($form->isSubmitted() && $form->isValid()) {
Wednesday, November 16, 2022

Upgrade to 3.4.*, because it's the latest LTS version. Updating to version 4 should be done when 4.4 comes out (it will be LTS version).

Try to adjust your configuration like following and run the composer update. Following configuration comes with autowiring. Consider if you want to use that, but I suggest, because it's more comfortable to get your dependencies in services/controllers at constructor by using type hints.

1) Composer.json

"symfony/symfony": "3.4.*",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"twig/twig": "^1.0||^2.0",
"symfony/monolog-bundle": "^3.1.0",

2) app/config/services.yml

        autowire: true # Automatically injects dependencies in your services
        autoconfigure: true
        public: false
            # Nice feature here. Local Binding. Read about it at documentation.

    # makes classes in AppBundle available to be used as services
        resource: '../../src/AppBundle/*'
    # exclude directories || files (if service is unused, it will be removed anyway)
        exclude: '../../src/AppBundle/{Entity,Repository,Tests}'
        resource: '../../src/AppBundle/Controller'
        public: true
        tags: ['controller.service_arguments']

3) AppBundle/Resources/config/services.yml

        autowire: true
        autoconfigure: true
        public: false
Friday, September 9, 2022

Do you use the same server/configuration when working with PhpStorm and Eclipse?

As it was explained in the comments, it has nothing to do with the IDE, but with the web server (Apache) and its configuration.

You can edit .htaccess with any editor, if this virtualhost/directory configuration has AllowOverride All, ModRewrite is enabled and your rewrite rules are correct, it will work just fine.

You need to ensure that your PHP files are served from the correctly configured web server.

Tuesday, August 9, 2022

You can do that with External Tools functionality.

The idea is to launch your app/script that will open such URL in a web browser.

How it can be done depends on your OS and tools you have got there. This is how it can be implemented on Windows OS (URL will be opened in your default web browser):

After you have create such external tool entry and it's working you can optionally assign custom shortcut. This can be done at Settings/Preferences | Keymap -- look for that entry under External Tools branch:

NOTE: Please note that if selection contains spaces then such search will partially fail as spaces will not be encoded into web safe + character (or %20) -- for such cases you will have to write shell/batch script that would perform such conversion and only then open such final URL.

Friday, November 4, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :