Simple.
Lightning fast.
A joy to develop with.
composer require neoan.io/core
mkdir src
mkdir public
(or however appropriate with your system)
...
"autoload": {
"psr-4": {
"App\\": "./src/",
}
...
composer dumpautoload
Your index.php should run in the root of the intended web-entry (usually /public)
// /public/index.php
use Neoan\NeoanApp;
use Neoan\Routing\Route;
use Neoan\Helper\Setup;
$projectPath = dirname(__DIR__);
require_once $projectPath . '/vendor/autoload.php';
$pathToSourceFiles = $projectPath . '/src';
$publicPath = __DIR__;
$setup = new Setup();
$setup->setLibraryPath($pathToSourceFiles)
->setPublicPath($publicPath);
$app = new NeoanApp($setup);
// register a test route
Route::get('/')->inject([
'msg' => 'Neoan LENKRAD is running'
]);
// run application
$app->run();
cd public
php -S localhost:8000 index.php
LENKRAD uses a database adapter to interact with databases in a standardized way. Own database adapters have to implement Neoan\Database\Adapter and be able to handle the easy-markup. For this quick setup we will assume the use of MySQL.
composer require neoan.io/legacy-db-adapter
use Neoan\Database\Database;
use NeoanIo\MarketPlace\DatabaseAdapter;
use Neoan\Helper\Env;
$dbClient = [
'host' => Env::get('DB_HOST', 'localhost'),
'name' => Env::get('DB_NAME', 'neoan_io'),
'port' => Env::get('DB_PORT', 3306),
'user' => Env::get('DB_USER', 'root'),
'password' => Env::get('DB_PASSWORD', ''),
'charset' => Env::get('DB_CHARSET', 'utf8mb4'),
'casing' => Env::get('DB_CASING', 'camel'),
'assumes_uuid' => Env::get('DB_UUID', false)
];
Database::connect(new DatabaseAdapter($dbClient));
It's up to you where you place this code. You could decide to place it as a middleware or in a general setup file. However, make sure to execute it prior to any model-interactions. In most cases you want to add this to your application bootstrapping after initialization of the app and before execution ($app->run())
However, let's set up the CLI application as well. The cli tool helps you with common tasks like migrating models or generating files.
touch cli
(or however appropriate with your system)
As we didn't use .php as a file extension, make sure to use the shebang line to execute as PHP.
#!/usr/bin/env php
?php
use Neoan\Cli\Application;
use Neoan\NeoanApp;
use Neoan\Helper\Setup;
$projectPath = __DIR__;
require_once $projectPath . '/vendor/autoload.php';
$setup = (new Setup())
->setLibraryPath($projectPath . '/src')
->setPublicPath($projectPath . '/public');
// Note that we add a second parameter here, the CLI-path
// In our case, it's the same as the project path
$app = new NeoanApp($setup, $projectPath);
// Now let's pass the initialized app into our console application
$console = new Application($app);
$console->run();
php cli list
The actual fastest way to get you to your application is by using one of the starter packages: Starter Projects