The file composer.json
looks as follows:
{
"name": "maxpronko/invoice-system",
"type": "project",
"autoload": {
"psr-4": {
"Invoice\\": "src/"
}
},
"minimum-stability": "stable",
"require": {}
}
Application Entry Point
Let’s create the file pub/index.php
that is an entry point of the application.
<?php
use Invoice\App;
require '../vendor/autoload.php';
$app = new App();
$app->run();
Please note that the location of the file autoload.php
should be modified as both the pub
and the vendor
directories are located on the same level.
The App PHP Class
The application App
class is located in the src
directory. The class represents a front controller of the web application. As for now, the run()
method renders the text “Invoice Management System” that can be seen via the browser.
<?php declare(strict_types=1);
namespace Invoice;
class App
{
public function run(): void
{
echo 'Invoice Management System';
}
}
Built-in PHP Server
For this application, I am going to use a built-in PHP server. Later, I am going to use docker containers for a web application, MySQL database.
Start a server:
cd pub/
php -S localhost:9999
Open a web browser and enjoy the result!
Leave a Reply
You must be logged in to post a comment.