Uploaded January 2018 | Updated December 2026, 26 minutes ago
In this video I explain how to use the Scope feature in PhpStorm. It is a very useful tool of the idea. One you should be taking advantage off.
Links:
jetbrains.com/help/phpstorm/scope.html
Reval Govender
LinkedIn: uk.linkedin.com/in/reval-govender-0ba14860
Twitter: twitter.com/RevalGovender
Laravel Tutorials:
youtube.com/playlist?list=PLrIm-p2rpV0FmbeNsYYh_4Fcb4Ibq29tJ
2 - 3 min Developer Quick Tips Series:
youtube.com/playlist?list=PLrIm-p2rpV0F6yyK99B9TU6yVhnPdzelB
PHP Developer Tutorials:
youtube.com/playlist?list=PLrIm-p2rpV0Fy93MCcC1Co0BuccJk6QqX
A Journey To TDD the tutorial series:
youtube.com/playlist?list=PLrIm-p2rpV0EWSkkE6Llxaw7sxnsxdVWB
In this video I explain how to use the Scope feature in PhpStorm. It is a very useful tool of the idea. One you should be taking advantage off.
Links:
jetbrains.com/help/phpstorm/scope.html
Reval Govender
LinkedIn: uk.linkedin.com/in/reval-govender-0ba14860
Twitter: twitter.com/RevalGovender
Laravel Tutorials:
youtube.com/playlist?list=PLrIm-p2rpV0FmbeNsYYh_4Fcb4Ibq29tJ
2 - 3 min Developer Quick Tips Series:
youtube.com/playlist?list=PLrIm-p2rpV0F6yyK99B9TU6yVhnPdzelB
PHP Developer Tutorials:
youtube.com/playlist?list=PLrIm-p2rpV0Fy93MCcC1Co0BuccJk6QqX
A Journey To TDD the tutorial series:
youtube.com/playlist?list=PLrIm-p2rpV0EWSkkE6Llxaw7sxnsxdVWB


![Part 5 - Install and Bootstrap Codeception [How to use TDD to build a REST API in Laravel 6]
Like I said in a previous video, I would like to do as many things within PhpStorm as I can. Let’s open up our version control panel. You might see some idea files. It is not common practice to commit this to the repository. The idea files contain configurations for the IDE on a per project basis. We can ignore them in this tutorial. Let’s update our .gitignore file. For simplicity, feel free to revert the idea files you may have too.
We can commit our changes, using Ctrl + K. Wherever possible, I am going to be using shortcuts. I will let you know what they are, the first time I use them.
Now, let’s install Codeception. To install codeception, run the composer command:
“composer require codeception/codeception dev”. The “ dev” flag will save Codeception as a dev requirement in our composer.json file. To speed up the download process, I will just skip ahead.
If we take a look in our project view, we can see our composer.json and composer.lock file has been updated. Let’s open up our composer.json. You can see Codeception has been added as a dev dependency.
Before we initialise Codeception. Let’s take a look at our Tests folder. We have some default Laravel stuff in here. Let’s get rid of it, to keep this folder clean. When we boootstrap Codeception, it will create new files here.
To bootstrap Codeception, open up the terminal. To save time, do this outside of Vagrant. Whenever you can do something, outside of the virtual machine, take the opportunity to do so. Whenever we run operations within the virtual machine, it is always going to be slower than out.
Run “vendor/bin/codecept”. This will give us a list of available commands. We want to use the Bootstrap command. So let’s run “vendor/bin/codecept bootstrap”. This will generate new files and folders in our test directory.
Let’s take a look. We now have Codeception installed and initialised. Let’s commit our work.
Watch next video:
https://youtu.be/JWW4r1xM4Q4
Watch this course in full here:
https://www.youtube.com/playlist?list=PLrIm-p2rpV0F-rl4NPjNslEmW-D83AHOr
Laravel Tutorials:
https://www.youtube.com/playlist?list=PLrIm-p2rpV0FmbeNsYYh_4Fcb4Ibq29tJ
2 - 3 min Developer Quick Tips Series:
https://www.youtube.com/playlist?list=PLrIm-p2rpV0F6yyK99B9TU6yVhnPdzelB Part 5 - Install and Bootstrap Codeception [How to use TDD to build a REST API in Laravel 6]](https://i.ytimg.com/vi/r_ttRXID8kE/mqdefault.jpg)







![Part 18-Handle failure gracefully Create endpoint [How to use TDD to build a REST API in Laravel 6]
We have some endpoints, but they aren’t the best. They don’t fail gracefully. Let’s take the Create endpoint for example. What happens if we provide a blank value for a required attribute?
The code will fail and throw an error but we don’t handle that error.
So let’s write a test in our StoreCest test file. When we have an invalid parameter in our request, the server must respond with a 400 error. So let’s write a test for that.
A good name for this test can be, “itWillReturn400WhenMissingRequiredParameter()”.
Our test should fail, because we are not handling any errors in the controller. Let’s change that.
Open your controller and navigate to the store method. Let’s use Laravel’s manual validator to make the Title field required. We know without this field, we cannot save a record to the database.
So what we need to do next is wrap most of this method in a try/catch block. So if there are any failures, we can handle it. The Laravel validator, will let us know if the validation has failed. If it has failed, we need to throw an exception. We can declare the message and the http status code.
Our catch block, will then return a response using the same http status code as well as the message. Now our test should pass. Run your tests. Great it passes. Good work.
Watch the next video in this series here:
https://youtu.be/iIrrrUCAM1w
Watch this course in full here:
https://www.youtube.com/playlist?list=PLrIm-p2rpV0F-rl4NPjNslEmW-D83AHOr
Laravel Tutorials:
https://www.youtube.com/playlist?list=PLrIm-p2rpV0FmbeNsYYh_4Fcb4Ibq29tJ
2 - 3 min Developer Quick Tips Series:
https://www.youtube.com/playlist?list=PLrIm-p2rpV0F6yyK99B9TU6yVhnPdzelBWatch this course in full here:
https://www.youtube.com/playlist?list=PLrIm-p2rpV0F-rl4NPjNslEmW-D83AHOr Part 18-Handle failure gracefully Create endpoint [How to use TDD to build a REST API in Laravel 6]](https://i.ytimg.com/vi/ugy6MEeeVWI/mqdefault.jpg)