ikoncept/fabriq

A CMS Framework by Ikoncept

Maintainers

Details

github.com/ikoncept/fabriq

Source

Installs: 132

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Language:Vue

0.1.20 2021-11-24 19:21 UTC

README

Latest Stable Version tests PHPStanLevel7 PHP Version Require

Fabriq CMS logo

Fabriq CMS

Installation instructions 💻

composer require ikoncept/fabriq

If you're planning on using AWS s3:

composer require --with-all-dependencies league/flysystem-aws-s3-v3 "^1.0"

You probably want to install Laravel Sanctum as well for authentication

composer require laravel/sanctum

Publish the configurations:

php artisan vendor:publish --provider="Ikoncept\Fabriq\FabriqCoreServiceProvider" --tag=config
php artisan vendor:publish --provider="Infab\TranslatableRevisions\TranslatableRevisionsServiceProvider" --tag=config

Setup your database using the .env

Run the fabriq:install command:

$ php artisan fabriq:install

This command will publish front end assets and views. It will also run the migrations

Important Delete the files app.js and bootstrap.js in the resources/js directory

rm resources/js/app.js && rm resources/js/bootstrap.js

Run yarn install and yarn production to build assets

$ yarn install && yarn production

Auth configuration 🗝

Enable the Laravel Sanctum middleware in app\Http\Kernel.php

    // app\Http\Kernel.php

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, // <---
            'throttle:api',
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
    ];

Modify the user model 🧘

The user model need to extend the Fabriq\Models\User::class

// app/Models/User.php

//...
use Ikoncept\Fabriq\Models\User as FabriqUser;
//...

class User extends FabriqUser

// ...

Register routes 🛣

Register the routes that makes sense for your app. See below examples

// routes/api.php

Fabriq::routes(function($router) {
    $router->forDevProtected();
},[
    'middleware' => ['auth:sanctum', 'role:dev', 'verified'],
    'prefix' => 'dev'
]);

Fabriq::routes(function($router) {
    $router->forApiAdminProtected();
},[
    'middleware' => ['auth:sanctum', 'role:admin', 'verified'],
    'prefix' => 'admin'
]);

Fabriq::routes(function($router) {
    $router->forApiProtected();
},[
    'middleware' => ['auth:sanctum']
]);

Fabriq::routes(function($router) {
    $router->forPublicApi();
});
// routes/web.php

use Ikoncept\Fabriq;

Fabriq::routes(
    function ($router) {
        $router->allWeb();
    }
);

Create your first user in the database, or by using a package like michaeldyrynda/laravel-make-user

Publishing assets 🗄️

Assets can be published using their respective tags. The tags that are available are:

  • config - The config file
  • fabriq-translations - Translations for auth views and validation messages
  • fabriq-frontend-assets - Front end build system and Vue project files
  • fabriq-views - Blade views and layouts

You can publish these assets using the command below:

$ php artisan vendor:publish --provider="Ikoncept\Fabriq\FabriqCoreServiceProvider" --tag=the-tag

If you want to overwrite your old published assets with new ones (for example when the package has updated views) you can use the --force flag

$ php artisan vendor:publish --provider="Ikoncept\Fabriq\FabriqCoreServiceProvider" --tag=fabriq-views --force

Note Above tags have been published when the fabriq:install was run

Done? 🎉

That should be it, serve the app and login at /login

License

The MIT License (MIT). Please see License File for more information.

Testing

$ composer test