| @@ -12,11 +12,11 @@ | |||||
| ] | ] | ||||
| }, | }, | ||||
| "scripts": { | "scripts": { | ||||
| "migrate": "php migrate.php up", | |||||
| "migrate:down": "php migrate.php down", | |||||
| "migrate:status": "php migrate.php status", | |||||
| "migrate:fresh": "php migrate.php fresh", | |||||
| "migrate:fresh-seed": "php migrate.php fresh --seed" | |||||
| "migrate": "php scripts/migrate.php up", | |||||
| "migrate:down": "php scripts/migrate.php down", | |||||
| "migrate:status": "php scripts/migrate.php status", | |||||
| "migrate:fresh": "php scripts/migrate.php fresh", | |||||
| "migrate:fresh-seed": "php scripts/migrate.php fresh --seed" | |||||
| }, | }, | ||||
| "require": {} | "require": {} | ||||
| } | } | ||||
| @@ -6,7 +6,7 @@ A small PHP MVC framework inspired by a Classic ASP MVC framework. | |||||
| ```bash | ```bash | ||||
| composer install | composer install | ||||
| php migrate.php up | |||||
| php scripts/migrate.php up | |||||
| php -S localhost:8000 -t public | php -S localhost:8000 -t public | ||||
| ``` | ``` | ||||
| @@ -41,6 +41,7 @@ Browser → public/index.php → Request → Dispatcher → Router → Route → | |||||
| - `app/Views/` PHP templates | - `app/Views/` PHP templates | ||||
| - `routes/web.php` route definitions | - `routes/web.php` route definitions | ||||
| - `database/migrations/` migrations | - `database/migrations/` migrations | ||||
| - `scripts/` runnable PHP CLI scripts | |||||
| ## SQLite | ## SQLite | ||||
| @@ -55,12 +56,13 @@ The database file is created automatically when the app first needs it. | |||||
| Run migrations from the PHP CLI: | Run migrations from the PHP CLI: | ||||
| ```bash | ```bash | ||||
| php migrate.php up | |||||
| php migrate.php down | |||||
| php migrate.php status | |||||
| php migrate.php make create_projects_table | |||||
| php migrate.php fresh | |||||
| php migrate.php fresh --seed | |||||
| php scripts/migrate.php up | |||||
| php scripts/migrate.php down | |||||
| php scripts/migrate.php status | |||||
| php scripts/migrate.php make create_projects_table | |||||
| php scripts/migrate.php fresh | |||||
| php scripts/migrate.php fresh --seed | |||||
| php scripts/seed_employees.php 1000 | |||||
| ``` | ``` | ||||
| ## Frontend Libraries | ## Frontend Libraries | ||||
| @@ -0,0 +1,18 @@ | |||||
| # Scripts | |||||
| This directory holds project PHP scripts that are meant to be run from the command line. | |||||
| Examples: | |||||
| ```bash | |||||
| php scripts/migrate.php up | |||||
| php scripts/migrate.php status | |||||
| php scripts/migrate.php fresh --seed | |||||
| php scripts/seed_employees.php 1000 | |||||
| ``` | |||||
| Guidelines: | |||||
| - Put CLI-only PHP entrypoints here. | |||||
| - Keep reusable logic in `core/`, `app/`, or `database/`. | |||||
| - Let scripts stay thin and call into application classes or helper functions. | |||||
| @@ -2,7 +2,7 @@ | |||||
| declare(strict_types=1); | declare(strict_types=1); | ||||
| require_once __DIR__ . '/vendor/autoload.php'; | |||||
| require_once __DIR__ . '/../vendor/autoload.php'; | |||||
| $command = $argv[1] ?? 'help'; | $command = $argv[1] ?? 'help'; | ||||
| $options = array_slice($argv, 2); | $options = array_slice($argv, 2); | ||||
| @@ -62,7 +62,7 @@ try { | |||||
| $name = $argv[2] ?? ''; | $name = $argv[2] ?? ''; | ||||
| if ($name === '') { | if ($name === '') { | ||||
| throw new InvalidArgumentException('Provide a migration name. Example: php migrate.php make create_projects_table'); | |||||
| throw new InvalidArgumentException('Provide a migration name. Example: php scripts/migrate.php make create_projects_table'); | |||||
| } | } | ||||
| $path = $manager->make($name); | $path = $manager->make($name); | ||||
| @@ -81,7 +81,7 @@ try { | |||||
| } | } | ||||
| if (in_array('--seed', $options, true)) { | if (in_array('--seed', $options, true)) { | ||||
| require __DIR__ . '/database/seed_employees.php'; | |||||
| require __DIR__ . '/../database/seed_employees.php'; | |||||
| seed_employees(1000, true); | seed_employees(1000, true); | ||||
| } | } | ||||
| @@ -92,11 +92,11 @@ try { | |||||
| default: | default: | ||||
| echo "Migration CLI" . PHP_EOL; | echo "Migration CLI" . PHP_EOL; | ||||
| echo "Usage:" . PHP_EOL; | echo "Usage:" . PHP_EOL; | ||||
| echo " php migrate.php up" . PHP_EOL; | |||||
| echo " php migrate.php down [steps]" . PHP_EOL; | |||||
| echo " php migrate.php status" . PHP_EOL; | |||||
| echo " php migrate.php make <name>" . PHP_EOL; | |||||
| echo " php migrate.php fresh [--seed]" . PHP_EOL; | |||||
| echo " php scripts/migrate.php up" . PHP_EOL; | |||||
| echo " php scripts/migrate.php down [steps]" . PHP_EOL; | |||||
| echo " php scripts/migrate.php status" . PHP_EOL; | |||||
| echo " php scripts/migrate.php make <name>" . PHP_EOL; | |||||
| echo " php scripts/migrate.php fresh [--seed]" . PHP_EOL; | |||||
| exit(0); | exit(0); | ||||
| } | } | ||||
| } catch (Throwable $exception) { | } catch (Throwable $exception) { | ||||
| @@ -0,0 +1,8 @@ | |||||
| <?php | |||||
| declare(strict_types=1); | |||||
| require_once __DIR__ . '/../database/seed_employees.php'; | |||||
| $targetTotal = isset($argv[1]) ? max(1, (int) $argv[1]) : 1000; | |||||
| seed_employees($targetTotal); | |||||
Powered by TurnKey Linux.