Skip to content

Commit

Permalink
Merge pull request #43: Add SF 3.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk authored Nov 28, 2024
2 parents 8b14e0c + d6ebf67 commit 2e04a41
Show file tree
Hide file tree
Showing 46 changed files with 794 additions and 600 deletions.
2 changes: 1 addition & 1 deletion .rr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '2.7'
version: '3'

rpc:
listen: tcp://127.0.0.1:6001
Expand Down
1 change: 0 additions & 1 deletion .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ enabled:
- linebreak_after_opening_tag
- single_quote
- no_blank_lines_after_phpdoc
- unary_operator_spaces
- no_useless_else
- no_useless_return
- trailing_comma_in_multiline_array
Expand Down
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Spiral Framework is a High-Performance PHP/Go Full-Stack framework and group of
Server Requirements
--------
Make sure that your server is configured with following PHP version and extensions:
* PHP 8.0+, 64bit
* PHP 8.1+, 64bit
* *mb-string* extension
* PDO Extension with desired database drivers (default SQLite)
* For FrontEnd build yarn and nodejs are required.
Expand Down Expand Up @@ -41,77 +41,80 @@ Demo Screenshot
Installation
--------
```
composer create-project spiral/app-keeper --stability dev
composer create-project spiral/app-keeper
cd app-keeper
yarn && yarn build
```

> **Note**
> Application server will be downloaded automatically (`php-curl` and `php-zip` required).
Once the application is installed you can ensure that it was configured properly by executing:

```
$ php app.php configure -vv
php app.php configure -vv
```

Migrate the database:

```
$ php app.php migrate:init
$ php app.php migrate
php app.php migrate:init
php app.php migrate
```

Seed user accounts:

```
$ php app.php user:seed
php app.php user:seed
```

Create super admin account:

```
$ php app.php user:create {First-Name} {Last-Name} {email-address} {password}
php app.php user:create {First-Name} {Last-Name} {email-address} {password}
```

To start application server execute:

```
$ ./rr serve -d
./rr serve -d
```

On Windows:

```
$ ./rr.exe serve -d
./rr.exe serve -d
```

Application will be available on `http://localhost:8080`. Keeper control panel available at `http://localhost:8080/keeper`.

> **Note**
> Read more about application server configuration [here](https://roadrunner.dev/docs). Make sure to turn `DEBUG` off in `.env` to enable view caching.
Testing:
--------
To test an application:

```bash
$ ./vendor/bin/phpunit
./vendor/bin/phpunit
```

Cloning:
--------
Make sure to properly configure project if you cloned the existing repository.

```bash
$ copy .env.sample .env
$ composer install
$ php app.php encrypt:key -m .env
$ php app.php configure -vv
$ php app.php migrate:init
$ php app.php migrate
$ ./vendor/bin/rr get
$ yarn build
copy .env.sample .env
composer install
php app.php encrypt:key -m .env
php app.php configure -vv
php app.php migrate:init
php app.php migrate
./vendor/bin/rr get
yarn build
```

> **Note**
> Make sure to create super-admin account.
Docker:
Expand All @@ -122,7 +125,7 @@ Requirements: Docker engine 19.03.0+
To launch Keeper in Docker create env file if needed.

```bash
copy .env.sample .env
copy .env.sample .env
```

Build and run for Linux and MacOS
Expand Down
32 changes: 12 additions & 20 deletions app.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,30 @@
<?php

/**
* This file is part of Spiral package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

use App\App;

//
// If you forgot to configure some of this in your php.ini file,
// then don't worry, we will set the standard environment
// settings for you.
//

mb_internal_encoding('UTF-8');
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'stderr');
\mb_internal_encoding('UTF-8');
\error_reporting(E_ALL | E_STRICT ^ E_DEPRECATED);
\ini_set('display_errors', 'stderr');

//
// Register Composer's auto loader.
//
require __DIR__ . '/vendor/autoload.php';


//
// Initialize shared container, bindings, directories and etc.
//
$app = App::init(['root' => __DIR__]);
$app = App::create(
directories: ['root' => __DIR__],
exceptionHandler: \App\Exception\Handler::class
)->run();

if ($app !== null) {
$code = (int)$app->serve();
exit($code);
if ($app === null) {
exit(255);
}

$code = (int)$app->serve();
exit($code);
98 changes: 61 additions & 37 deletions app/src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,103 +5,127 @@
namespace App;

use App\Bootloader;
use Spiral\Boot\Bootloader\CoreBootloader;
use Spiral\Bootloader as Framework;
use Spiral\DataGrid\Bootloader\GridBootloader;
use Spiral\Distribution\Bootloader\DistributionBootloader;
use Spiral\DotEnv\Bootloader as DotEnv;
use Spiral\Framework\Kernel;
use Spiral\Monolog\Bootloader as Monolog;
use Spiral\Nyholm\Bootloader as Nyholm;
use Spiral\Prototype\Bootloader as Prototype;
use Spiral\Router\Bootloader as Router;
use Spiral\Sapi\Bootloader\SapiBootloader;
use Spiral\Scaffolder\Bootloader as Scaffolder;
use Spiral\Stempler\Bootloader as Stempler;
use Spiral\Storage\Bootloader\StorageBootloader;
use Spiral\Tokenizer\Bootloader\TokenizerBootloader;
use Spiral\Validation\Bootloader\ValidationBootloader;
use Spiral\Views\Bootloader\ViewsBootloader;
use Spiral\Writeaway\Bootloader as Writeaway;
use Spiral\Cycle\Bootloader as CycleBridge;
use Spiral\RoadRunnerBridge\Bootloader as RoadRunnerBridge;

class App extends Kernel
{
protected const SYSTEM = [
CoreBootloader::class,
TokenizerBootloader::class,
DotEnv\DotenvBootloader::class,
];

/*
* List of components and extensions to be automatically registered
* within system container on application start.
*/
protected const LOAD = [
/** -- roadrunner -- */
// Logging and exceptions handling
Monolog\MonologBootloader::class,
Bootloader\ExceptionHandlerBootloader::class,

// Application specific logs
Bootloader\LoggingBootloader::class,

// RoadRunner
RoadRunnerBridge\CacheBootloader::class,
RoadRunnerBridge\GRPCBootloader::class,
RoadRunnerBridge\HttpBootloader::class,
RoadRunnerBridge\QueueBootloader::class,
RoadRunnerBridge\CommandBootloader::class,
RoadRunnerBridge\RoadRunnerBootloader::class,

/* -- debug and profiling --*/
DotEnv\DotenvBootloader::class,
Monolog\MonologBootloader::class,
// Core Services
Framework\SnapshotsBootloader::class,
Framework\DebugBootloader::class,
Framework\Debug\LogCollectorBootloader::class,
Framework\Debug\HttpCollectorBootloader::class,

/* -- application specific logging --*/
Bootloader\LoggingBootloader::class,
Framework\I18nBootloader::class,

/* -- validation, security and encryption --*/
// Security and validation
Framework\Security\EncrypterBootloader::class,
Framework\Security\ValidationBootloader::class,
ValidationBootloader::class,
Framework\Security\FiltersBootloader::class,
Framework\Security\GuardBootloader::class,

/* -- HTTP --*/
// HTTP extensions
Nyholm\NyholmBootloader::class,
Framework\Http\ErrorHandlerBootloader::class,
Framework\Http\RouterBootloader::class,
Framework\Http\JsonPayloadsBootloader::class,
Framework\Http\CookiesBootloader::class,
Framework\Http\SessionBootloader::class,
Framework\Http\CsrfBootloader::class,
Framework\Http\PaginationBootloader::class,
Framework\Http\RouterBootloader::class,
Framework\Http\JsonPayloadsBootloader::class,
SapiBootloader::class,
Router\AnnotatedRoutesBootloader::class,

/* -- ORM and databases --*/
// Databases
CycleBridge\DatabaseBootloader::class,
CycleBridge\MigrationsBootloader::class,
CycleBridge\DisconnectsBootloader::class,
// CycleBridge\DisconnectsBootloader::class,

// ORM
CycleBridge\SchemaBootloader::class,
CycleBridge\CycleOrmBootloader::class,
CycleBridge\AnnotatedBootloader::class,
CycleBridge\CommandBootloader::class,

// DataGrid
GridBootloader::class,
CycleBridge\DataGridBootloader::class,

// Writeaway
Writeaway\WriteawayBootloader::class,
Writeaway\WriteawayCommandBootloader::class,
Writeaway\WriteawayViewsBootloader::class,

/* -- stempler and views --*/
Framework\Views\ViewsBootloader::class,
// Stempler and views
ViewsBootloader::class,
Framework\Views\TranslatedCacheBootloader::class,
Stempler\StemplerBootloader::class,
Stempler\PrettyPrintBootloader::class,

/* -- security and auth context --*/
// Security and auth context
Framework\Auth\HttpAuthBootloader::class,
CycleBridge\AuthTokensBootloader::class,
Framework\Auth\SecurityActorBootloader::class,

/* -- other components --*/
Framework\I18nBootloader::class,
Framework\Storage\StorageBootloader::class,
Framework\Distribution\DistributionBootloader::class,

/* -- data rendering --*/
CycleBridge\DataGridBootloader::class,
// Other components
StorageBootloader::class,
DistributionBootloader::class,

/* -- routes and middleware -- */
Router\AnnotatedRoutesBootloader::class,
Bootloader\LocaleSelectorBootloader::class,

/* -- security and admin panels --*/
// Security and admin panels
Bootloader\SecurityBootloader::class,
Bootloader\AdminBootloader::class,

/* -- development helpers --*/
// Development helpers
Framework\CommandBootloader::class,
Prototype\PrototypeBootloader::class,
Scaffolder\ScaffolderBootloader::class,

//App
// App
Bootloader\RoutesBootloader::class,
Bootloader\AppBootloader::class,

// fast code prototyping
Prototype\PrototypeBootloader::class,
];

protected const APP = [
// ...
];
}
16 changes: 10 additions & 6 deletions app/src/Bootloader/AdminBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
namespace App\Bootloader;

use App\Controller\Keeper\DashboardController;
use Spiral\Cycle\DataGrid\Interceptor\GridInterceptor;
use App\Interceptor\ValidationInterceptor;
use Spiral\Core\Container\Autowire;
use Spiral\DataGrid\Interceptor\GridInterceptor;
use Spiral\Cycle\Interceptor\CycleInterceptor;
use Spiral\Domain\FilterInterceptor;
use Spiral\Domain\GuardInterceptor;
use Spiral\Keeper\Bootloader as Keeper;
use Spiral\Keeper\Bootloader\KeeperBootloader;
Expand All @@ -26,11 +27,14 @@ class AdminBootloader extends KeeperBootloader
protected const INTERCEPTORS = [
CycleInterceptor::class,
GuardInterceptor::class,
FilterInterceptor::class,
ValidationInterceptor::class,
GridInterceptor::class,
];

protected const MIDDLEWARE = [
LoginMiddleware::class,
];
protected function getMiddleware(): array
{
return [
new Autowire(LoginMiddleware::class, ['loginView' => 'keeper:login']),
];
}
}
Loading

0 comments on commit 2e04a41

Please sign in to comment.