Update README.md, remove migration.php, add message to browser.php
This commit is contained in:
@@ -2,5 +2,9 @@
|
||||
|
||||
## Project start
|
||||
|
||||
1. Run `migration.php` file to create `database.sqlite` and create tables.
|
||||
2. Run `php index.php app:scrape` command to scrape all the products from the ryobi website.
|
||||
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.
|
||||
6. Access web interface using `localhost:9000` address in web browser.
|
||||
@@ -6,6 +6,10 @@ use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Krzysiej\RyobiCrawler\Models\Product;
|
||||
use Twig\{Environment, Loader\FilesystemLoader};
|
||||
|
||||
if (!file_exists('database.sqlite')) {
|
||||
exit('Database file <code>database.sqlite</code> missing. Run docker compose <blockquote>docker compose exec php-app php index.php app:migrate</blockquote> to create it.');
|
||||
}
|
||||
|
||||
$capsule = new Capsule;
|
||||
$capsule->addConnection(['driver' => 'sqlite', 'database' => __DIR__ . '/database.sqlite']);
|
||||
$capsule->setAsGlobal();
|
||||
|
||||
@@ -13,7 +13,7 @@ if (php_sapi_name() !== 'cli') {
|
||||
exit;
|
||||
}
|
||||
|
||||
$application = new Application('Ryobi website scraper application', '1.1.0');
|
||||
$application = new Application('Ryobi website scraper application', '1.1.1');
|
||||
$application->add(new ScrapeWebsite());
|
||||
$application->add(new Migrate());
|
||||
$application->run();
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
include_once 'vendor/autoload.php';
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
echo 'Execute this script in cli only';
|
||||
exit;
|
||||
}
|
||||
touch('database.sqlite');
|
||||
$capsule = new Capsule;
|
||||
$capsule->addConnection([
|
||||
'driver' => 'sqlite',
|
||||
'database' => __DIR__ . '/database.sqlite',
|
||||
]);
|
||||
$capsule->setAsGlobal();
|
||||
|
||||
if (!Capsule::schema()->hasTable('products')) {
|
||||
Capsule::schema()->create('products', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->integer('skuID')->unique();
|
||||
$table->integer('agilityID');
|
||||
$table->integer('availableQuantity');
|
||||
$table->integer('stock');
|
||||
$table->json('categories');
|
||||
$table->string('image');
|
||||
$table->string('subTitle');
|
||||
$table->string('variantCode');
|
||||
$table->string('modelCode');
|
||||
$table->string('url');
|
||||
$table->boolean('starred')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (!Capsule::schema()->hasTable('prices')) {
|
||||
Capsule::schema()->create('prices', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->foreignId('product_id');
|
||||
$table->float('price');
|
||||
$table->float('productStandardPrice');
|
||||
$table->float('lowestProductPrice30Days');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user