Please read this section at least one day prior to the seminar. This section outlines what you are expected to know, be able to do, or prepare in advance. Following these instructions will help you get the most out of the seminar and ensure smooth participation.
Before the start of the practical, you should be able to:
Overall it is enough to go through the basic tutorial of each library.
You will work in pairs on this practical. As a result, you can split the libraries to explore with your colleague.
This slide applies to you only if you plan to use your own computer for the practical.
Please keep in mind, that you will work in pairs using a single computer. Thus consider bringing your own mouse and keyboard.
Before the start of the practical, make sure that:
php --version
php composer.phar
Run those command before we get to exercise to download dependencies.
php composer.phar init --no-interaction
php composer.phar require slim/slim slim/psr7 monolog/monolog php-di/php-di
The basic utilization is explained in the using Monolog documentation.
Selected concepts you should be familiar with.
The HTTP message interfaces specify a way of interaction with HTTP. It is an alternative to using HTTP wrapper ($_GET, $_POST, etc.).
Slim is a PSR-7 compliant micro framework for PHP. To use Slim with PSR-7 we need to install PSR-7 binding.
At its core, Slim is a dispatcher that receives an HTTP request, invokes an appropriate callback routine, and returns an HTTP response. That's it.
What are your expectations of a mature PHP web application? It is quite likely that the expectations are not uniq. You can utilize Slim framework skeleton project instead of starting from 0. Yet, this is not what we do today as the skeleton is quite complex
php .\composer.phar create-project slim/slim-skeleton slim-framework-skeleton
Ask yourself: Can your package manager do this?
As the skeleton slim application is too big, we create a new application from scratch. There is a useful Get Started guide. Here are the steps to follow:
composer require slim/slim
composer require slim/psr7
php -S 127.0.0.1:8090 -t .\public\
The driver writes the code.
The navigator reviews each line as it's written, thinks about the bigger picture, spots mistakes early, and asks questions.
You are both owners of the code. As such you are both responsible and you will both build on it later.
Note: This is not the only way to develop code in pairs. The driver / navigator approach was modified to fit the practicals.
You are building a REST API for a simple Book Library. There is no real database; use a PHP arrays as your data store.
Prepare your project using following steps.
php composer.phar init
php composer.phar require slim/slim slim/psr7 monolog/monolog php-di/php-di
Download index start and save it as "./public/index.php". This is your starting file. The file also contains instrcutions.
You can start local server using.
php -S 127.0.0.1:8090 -t .\public\
As PHP server reads the files with every request there is no need to stop or restart the server as you develop your application.
Continue to the next slide once you are done >>>
This is just the beginning.
Now you can either:
Congratulations, if you have followed the instructions, you have just reached the end of this exercise.
GitLab: ./practical-03/
Continue with the previous code you created with your partner. The objective is to expand the functionality by extending the use of libraries. You should already be familiar with many of the concepts from the NSWI142.
Do not forget to not only deploy your application, see instruction at the end of the exercise. But also commit and push into your repository.
Continue to the next slide once you are done >>>
Update your application so that it:
If you struggle with PHP-DI integration, take a look at PHP definitions documentation.
Continue to the next slide once you are done >>>
Update your application so that it:
Create a layout for your application. The layout must include a navigation header with your custom brand name; just make something up. In addition, it must include footer with a following copyright notice.
© 2025-2026 NSWI153
Continue to the next slide once you are done >>>
Deploy your application to webik.ms.mff.cuni.cz/~{your-user-name}/nswi153/practical-03.
When running your application at webik, make sure you properly set ACL. You can do that using following command:
setfacl -m u:www-data:rwx ./log/
Make sure application works as intended! You may find following resources useful.
Congratulations, if you have followed the instructions, you have just reached the end of this exercise.