Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Testing the Code from a PR

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

It looks like Colin did a great job with this new feature. But, we can give a merger much more confidence by actually testing it in a real project!

Creating a new Test App

In PhpStorm, I've already created an empty contributing directory. And, I already have a terminal open to this same place. To test the PR, let's literally create a brand-new Symfony app:

composer create-project symfony/skeleton

I'm using symfony/skeleton instead of the larger symfony/website-skeleton to keep things as small and focused as possible. Grab the dev-master version of the skeleton:

composer create-project symfony/skeleton:dev-master

Why? Colin's PR is against Symfony's master branch. So, to test it, I want to create an app that's based on that same version of Symfony.

Finally, put this into a new directory called triage_pr_28069:

composer create-project symfony/skeleton:dev-master triage_pr_28069

When that finishes, move over and... yea! Here's the new app. Check out its composer.json file:

... lines 2 - 4
"require": {
... lines 6 - 8
"symfony/console": "^4.2",
... line 10
"symfony/force-lowest": "=4.2",
"symfony/framework-bundle": "^4.2",
"symfony/yaml": "^4.2"
"require-dev": {
"symfony/dotenv": "^4.2"
... lines 18 - 60

It's using version 4.2 of Symfony, which is the next, unreleased, version of Symfony at this moment. In other words, this code is from Symfony's master branch. We also have minimum-stability set to dev:

... lines 2 - 3
"minimum-stability": "dev",
... lines 5 - 60

Which means that Composer will try to install new, unreleased version of libraries.

Look back at the PR: all of the changes were to the Validator component. Ok, let's get that installed: find your terminal, move into the directory and run:

composer require validator

This will install the dev-master version of symfony/validator. In other words, it will get the code from Symfony's master branch. But... hmm... that's not quite what we want: we somehow need to get the code from Colin's branch. How can we do that? Oh, it's super cool.

Getting the Code from the Pull Request

Go to your terminal and open a new tab. Go back up to the contributing directory. I'm going to clone the entire Symfony project into a new directory here. To do that, go back to your browser, move to the repository's homepage, click "Clone or download" and copy the URL.

Move back over, git clone and paste:

git clone git@github.com:symfony/symfony.git

When that finishes, we now have a symfony directory right next to our app. To get Colin's branch, we have a few options. Move into the new symfony directory:

cd symfony/

And type:

git remote


git remote show origin

Let's add a second remote for Colin's fork. Copy the Symfony URL, then run git remote add and paste. Copy Colin's username - colinodell, move back, call the new remote colinodell, and change the username part of the URL:

git remote add colinodell git@github.com:colinodell/symfony.git

Nice! Grab his branches with:

git fetch colinodell

Yep! There's the branch: feature/multiple-of-validator - this is the one used for the PR. To check out to that code, create a new branch:

git checkout -b feature/multiple-of-validator colinodell/feature/multiple-of-validator

Sweet! To prove we've got the right code, go back to PhpStorm, press Shift+Shift, and search for the new file. There it is!

We now have a test app and the new code in our symfony directory. But, they're not connected yet! Let's do that next.

Leave a comment!

Login or Register to join the conversation
Robertas Š. Avatar
Robertas Š. Avatar Robertas Š. | posted 3 years ago

When I use:
git clone git@github.com:symfony/symfony.git

I get:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.


Hey Robertas,

Looks like you didn't set up GitHub SSH key properly. As a workaround, you can clone by HTTPS instead of SSH, just use this command:

$ git clone https://github.com/symfony/symfony.git

On GitHub you can choose what way you would like to clone the repo when you click on "Clone or download" green button, notice "Use HTTPS" link in the dropdown.

To be able to clone by SSH, you would need to register your key on GitHub, here's the page where you can do this: https://github.com/settings/keys . Just follow the official guide for this: https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh


Robertas Š. Avatar
Robertas Š. Avatar Robertas Š. | Victor | posted 3 years ago

Hi Victor,

Thank you for help, I will give a try.

Cat in space

"Houston: no signs of life"
Start the conversation!

The concepts in this tutorial work great for Symfony 5!