diff --git a/README.md b/README.md
index 4a79a08..b05dacd 100644
--- a/README.md
+++ b/README.md
@@ -5,10 +5,17 @@
1. Clone repository using `git clone https://git.techtube.pl/krzysiej/ryobi-crawler.git`
2. Cd into project directory `cd ryobi-crawler`
3. Build and start docker container `docker compose up -d`
-4. Run `docker compose exec php-app php index.php app:migrate` file to create `database.sqlite` and create tables.
-5. Run `docker compose exec php-app php index.php app:scrape` command to scrape all the products from the ryobi website.
+4. Run `docker compose exec php-app php console.php app:migrate` file to create `database.sqlite` and create tables.
+5. Run `docker compose exec php-app php console.php app:scrape` command to scrape all the products from the ryobi website.
6. Access web interface using `localhost:9000` address in web browser.
+
+## Update project
+
+1. Cd into project directory
+2. Run `git pull`
+3. Start and build image in one go with command: `docker compose up -d --build --force-recreate`
+
## Screenshots
### Main screen of the web view
diff --git a/browser.php b/browser.php
deleted file mode 100644
index f0ad083..0000000
--- a/browser.php
+++ /dev/null
@@ -1,48 +0,0 @@
-database.sqlite missing. Run docker compose
docker compose exec php-app php index.php app:migrate
to create it.');
-}
-$productRoute = new Route('/browser.php/product/{product_id}', ['_controller' => ProductController::class], ['product_id' => '\d+']);
-$searchRoute = new Route('/browser.php?search={search_term}', ['_controller' => SearchController::class]);
-$categoryRoute = new Route('/browser.php/category/{category_name}', ['_controller' => CategoryController::class]);
-$starRoute = new Route('/browser.php/star/{product_id}', ['_controller' => StarController::class]);
-$indexRoute = new Route('/browser.php', ['_controller' => IndexController::class]);
-$routes = new RouteCollection();
-
-$routes->add('product_show', $productRoute);
-$routes->add('search_show', $searchRoute);
-$routes->add('category_show', $categoryRoute);
-$routes->add('start_show', $starRoute);
-$routes->add('index_show', $indexRoute);
-
-$context = new RequestContext();
-$matcher = new UrlMatcher($routes, $context);
-try {
- $parameters = $matcher->match($_SERVER['REQUEST_URI']);
-} catch (Exception $e) {
- die($e->getMessage());
-}
-
-match ($parameters['_controller']) {
- SearchController::class => (new $parameters['_controller']())($parameters['search_term']),
- CategoryController::class => (new $parameters['_controller']())($parameters['category_name']),
- ProductController::class, StarController::class => (new $parameters['_controller']())($parameters['product_id']),
- IndexController::class => (new $parameters['_controller']())(),
- default => throw new Exception('Route not found')
-};
diff --git a/console.php b/console.php
new file mode 100644
index 0000000..c18dca1
--- /dev/null
+++ b/console.php
@@ -0,0 +1,19 @@
+add(new ScrapeWebsite());
+$application->add(new Migrate());
+$application->run();
diff --git a/index.php b/index.php
index c18dca1..2f928bc 100644
--- a/index.php
+++ b/index.php
@@ -2,18 +2,44 @@
include_once 'vendor/autoload.php';
-use Krzysiej\RyobiCrawler\Command\Migrate;
-use Krzysiej\RyobiCrawler\Command\ScrapeWebsite;
+use Krzysiej\RyobiCrawler\Controller\CategoryController;
+use Krzysiej\RyobiCrawler\Controller\IndexController;
+use Krzysiej\RyobiCrawler\Controller\ProductController;
+use Krzysiej\RyobiCrawler\Controller\SearchController;
+use Krzysiej\RyobiCrawler\Controller\StarController;
+use Symfony\Component\Routing\Matcher\UrlMatcher;
+use Symfony\Component\Routing\RequestContext;
+use Symfony\Component\Routing\Route;
+use Symfony\Component\Routing\RouteCollection;
-use Symfony\Component\Console\Application;
+if (!file_exists('database.sqlite')) {
+ exit('Database file database.sqlite missing. Run docker compose docker compose exec php-app php index.php app:migrate
to create it.');
+}
+$productRoute = new Route('/product/{product_id}', ['_controller' => ProductController::class], ['product_id' => '\d+']);
+$searchRoute = new Route('/?search={search_term}', ['_controller' => SearchController::class]);
+$categoryRoute = new Route('/category/{category_name}', ['_controller' => CategoryController::class]);
+$starRoute = new Route('/star/{product_id}', ['_controller' => StarController::class]);
+$indexRoute = new Route('/', ['_controller' => IndexController::class]);
+$routes = new RouteCollection();
-if (php_sapi_name() !== 'cli') {
- header('Location: browser.php');
- echo 'Execute this script in cli only';
- exit;
+$routes->add('product_show', $productRoute);
+$routes->add('search_show', $searchRoute);
+$routes->add('category_show', $categoryRoute);
+$routes->add('start_show', $starRoute);
+$routes->add('index_show', $indexRoute);
+
+$context = new RequestContext();
+$matcher = new UrlMatcher($routes, $context);
+try {
+ $parameters = $matcher->match($_SERVER['REQUEST_URI']);
+} catch (Exception $e) {
+ die($e->getMessage());
}
-$application = new Application('Ryobi website scraper application', '1.1.1');
-$application->add(new ScrapeWebsite());
-$application->add(new Migrate());
-$application->run();
+match ($parameters['_controller']) {
+ SearchController::class => (new $parameters['_controller']())($parameters['search_term']),
+ CategoryController::class => (new $parameters['_controller']())($parameters['category_name']),
+ ProductController::class, StarController::class => (new $parameters['_controller']())($parameters['product_id']),
+ IndexController::class => (new $parameters['_controller']())(),
+ default => throw new Exception('Route not found')
+};
diff --git a/src/templates/product.html.twig b/src/templates/product.html.twig
index c56c4ea..68f72b2 100644
--- a/src/templates/product.html.twig
+++ b/src/templates/product.html.twig
@@ -3,14 +3,14 @@
{% block content %}