2017 © Pedro Peláez
 

project dot-admin

Dotkernel Admin Application

image

dotkernel/dot-admin

Dotkernel Admin Application

  • Wednesday, March 22, 2017
  • by dotkernel
  • Repository
  • 5 Watchers
  • 2 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

admin

DotKernel web starter package suitable for admin applications., (*1)

OSS Lifecycle PHP from Packagist (specify version), (*2)

GitHub issues GitHub forks GitHub stars GitHub license, (*3)

Build Static codecov Qodana PHPStan, (*4)

Installing DotKernel admin

Tools

DotKernel can be installed through a single command that utilizes Composer. Because of that, Composer is required to install DotKernel admin., (*5)

Composer

Installation instructions:, (*6)

If you have never used composer before make sure you read the Composer Basic Usage section in Composer's documentation, (*7)

Choosing an installation path for DotKernel admin

Example:, (*8)

  • absolute path /var/www/dk-admin
  • or relative path dk-admin (equivalent with ./dk-admin)

Installing DotKernel admin

After choosing the path for DotKernel (dk-admin will be used for the remainder of this example) it must be installed. There are two installation methods., (*9)

I. Installing DotKernel admin using composer

please use the below CLI commands in terminal, do NOT use the PhpStorm buttons, (*10)

The advantage of using this command is that it runs through the whole installation process. Run the following command:, (*11)

composer create-project dotkernel/admin -s dev dk

The above command downloads the admin package, then downloads and installs the dependencies., (*12)

The setup script prompts for some configuration settings, for example the lines below:, (*13)

Please select which config file you wish to inject 'Laminas\Diactoros\ConfigProvider' into:
  [0] Do not inject
  [1] config/config.php
  Make your selection (default is 1):

Simply select [0] Do not inject, because DotKernel includes its own configProvider which already contains the prompted configurations., (*14)

If you choose [1] config/config.php Laminas's ConfigProvider from session will be injected., (*15)

The next question is:, (*16)

Remember this option for other packages of the same type? (y/N), (*17)

Type y here, and hit enter, (*18)

II. Installing DotKernel admin using git clone

This method requires more manual input, but it ensures that the default branch is installed, even if it is not released. Run the following command:, (*19)

git clone https://github.com/dotkernel/admin.git .

The dependencies have to be installed separately, by running this command, (*20)

composer install

Just like for II Installing DotKernel admin using composer (see above), the setup asks for configuration settings regarding injections (type 0 and hit enter) and a confirmation to use this setting for other packages (type y and hit enter), (*21)

Configuration - First Run

  • Remove the .dist extension from the files config/autoload/local.php.dist
  • Edit config/autoload/local.php according to your dev machine and fill in the database configuration

Run the migrations and seeds with these commands:, (*22)

php bin/doctrine-migrations migrate

php bin/doctrine fixtures:execute
  • If you use composer create-project, the project will go into development mode automatically after installing. The development mode status can be checked and toggled by using these composer commands:, (*23)

    composer development-status, (*24)

    composer development-enable, (*25)

    composer development-disable, (*26)

  • If not already done on installation, remove the .dist extension from config/autoload/development.global.php.dist. This will enable dev mode by turning debug flag to true and turning configuration caching to off. It will also make sure that any existing config cache is cleared., (*27)

Charset recommendation: utf8mb4_general_ci, (*28)

Manage GeoLite2 database

You can download/update a specific GeoLite2 database, by running the following command:, (*29)

php bin/cli.php geoip:synchronize -d {DATABASE}

Where {DATABASE} takes one of the following values: asn, city, country., (*30)

You can download/update all GeoLite2 databases at once, by running the following command:, (*31)

php bin/cli.php geoip:synchronize

The output should be similar to the below, displaying per row: database identifier: previous build datetime -> current build datetime., (*32)

asn: n/a -> 2021-07-01 02:09:34, (*33)

city: n/a -> 2021-07-01 02:09:20, (*34)

country: n/a -> 2021-07-01 02:05:12, (*35)

Get help for this command by running:, (*36)

php bin/cli.php help geoip:synchronize

Tip: If you setup the synchronizer command as a cronjob, you can add the -q|--quiet option, and it will output data only if an error has occurred., (*37)

NPM Commands

To install dependencies into the node_modules directory run this command., (*38)

npm install

If npm install fails, this could be caused by user permissions of npm. Recommendation is to install npm through Node Version Manager., (*39)

The watch command compiles the components then watches the files and recompiles when one of them changes., (*40)

npm run watch

After all updates are done, this command compiles the assets locally, minifies them and makes them ready for production., (*41)

npm run prod

Authorization Guards

The packages responsible for restricting access to certain parts of the application are dot-rbac-guard and dot-rbac. These packages work together to create an infrastructure that is customizable and diversified to manage user access to the platform by specifying the type of role the user has., (*42)

The authorization.global.php file provides multiple configurations specifying multiple roles as well as the types of permissions to which these roles have access., (*43)

'roles' => [
    'superuser' => [
        'permissions' => [
            'authenticated',
            'edit',
            'delete',
            //etc..
        ]
    ],
    'admin' => [
        'permissions' => [
            'authenticated',
            //etc..
        ]
    ]
]

The authorization-guards.global.php file provides configuration to restrict access to certain actions based on the permissions defined in authorization.global.php so basically we have to add the permissions in the dot-rbac configuration file first to specify the action restriction permissions., (*44)

'rules' => [
  [
      'route' => 'account',
      'actions' => [//list of actions to apply , or empty array for all actions
          'unregister',
          'avatar',
          'details',
          'changePassword'
      ],
      'permissions' => ['authenticated']
  ],
  [
      'route' => 'admin',
      'actions' => [
          'deleteAccount'
      ],
       'permissions' => [
          'delete'
          //list of roles to allow
      ]
  ]
]

Testing (Running)

Note: Do not enable dev mode in production, (*45)

  • Run the following command in your project's directory to start PHPs built-in server:, (*46)

    php -S 0.0.0.0:8080 -t public, (*47)

Running command composer serve will do the exact same, but the above is faster., (*48)

0.0.0.0 means that the server is open to all incoming connections 127.0.0.1 means that the server can only be accessed locally (localhost only) 8080 the port on which the server is started (the listening port for the server), (*49)

NOTE: If you are still getting exceptions or errors regarding some missing services, try running the following command, (*50)

php bin/clear-config-cache.php

If config-cache.php is present that config will be loaded regardless of the ConfigAggregator::ENABLE_CACHE in config/autoload/mezzio.global.php, (*51)

  • Open a web browser and visit http://localhost:8080/

You should see the DotKernel admin login page., (*52)

If you ran the migrations you will have an admin user in the database with the following credentials:, (*53)

  • User: admin
  • Password: dotadmin

NOTE:, (*54)

  • Production only: Make sure you modify the default admin credentials.
  • Development only: session.cookie_secure does not work locally so make sure you modify your local.php, as per the following:, (*55)

    return [ 'session_config' => [ 'cookie_secure' => false, ] ];, (*56)

Do not change this in local.php.dist as well because this value should remain true on production., (*57)

The Versions

22/03 2017

dev-master

9999999-dev

Dotkernel Admin Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by n3vrax

22/03 2017

0.2.2

0.2.2.0

Dotkernel Admin Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by n3vrax

22/03 2017

dev-develop

dev-develop

Dotkernel Admin Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by n3vrax

22/03 2017

dev-ui-develop

dev-ui-develop

Dotkernel Admin Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by n3vrax

22/03 2017

0.2.1

0.2.1.0

Dotkernel Admin Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by n3vrax

22/03 2017

0.2.0

0.2.0.0

Dotkernel Admin Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by n3vrax

12/03 2017

0.1.1

0.1.1.0

Dotkernel Admin Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by n3vrax

12/03 2017

0.1.0

0.1.0.0

Dotkernel Admin Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by n3vrax