Coder Social home page Coder Social logo

fr0z3nfyr / cakephp3-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ivanamat/cakephp3-app

0.0 1.0 0.0 74 KB

A skeleton for creating applications with CakePHP 3.x. The skeleton has been preloaded with the Acl and AclManager plugins. Manages groups, roles, users and ACL.

Shell 1.11% Batchfile 0.66% PHP 90.99% CSS 7.24%

cakephp3-app's Introduction

CakePHP Application Skeleton

Build Status License

A skeleton for creating applications with CakePHP 3.x. The skeleton has been preloaded with the Acl, AclManager, Markdown and Documents plugins. Manages groups, roles, users and ACL.

Loaded plugins

Installation

  1. Download Composer or update composer self-update.
  2. Run php composer.phar create-project --prefer-dist ivanamat/cakeapp [app_name].

If Composer is installed globally, run

composer create-project --prefer-dist ivanamat/cakeapp [app_name]

You should now be able to visit the path to where you installed the app and see the setup traffic lights.

Configuration

MySQL

Import the config/schema/cakephp.sql file to your database.

APP

Read and edit config/app.php and setup the 'Datasources' and any other configuration relevant for your application.

Uncomment $this->Auth->allow(); from initialize function on AppController. This lets you create Groups, Roles and Users.

public function initialize() {
    parent::initialize();

    $this->loadComponent('RequestHandler');
    $this->loadComponent('Flash');
    $this->loadComponent('Auth', [
        'authorize' => [
            'Acl.Actions' => ['actionPath' => 'controllers/']
        ],
        'loginAction' => [
            'plugin' => false,
            'controller' => 'Users',
            'action' => 'login'
        ],
        'loginRedirect' => [
            'plugin' => false,
            'controller' => 'Users',
            'action' => 'index'
        ],
        'logoutRedirect' => [
            'plugin' => false,
            'controller' => 'Users',
            'action' => 'login'
        ],
        'unauthorizedRedirect' => [
            'controller' => 'Pages',
            'action' => 'display',
            'prefix' => false
        ],
        'authError' => 'You are not authorized to access that location.',
        'flash' => [
            'element' => 'error'
        ]
    ]);
    
    // Only for ACL setup
    $this->Auth->allow();
}

Uncumment return true; from isAuthorized function on AppController. This allows you to access the Acl Manager plugin.

public function isAuthorized($user) {
    // Only for ACL setup
    return true;
    
    // Admin can access every action
    if (isset($user['role_id']) && $user['role_id'] === 1) {
        return true;
    }

    // Default deny
    return false;
}

Create the first group, the main role and the first user.

  • Now go to the Groups area and create your first group.
  • Access Roles area and create a new role for the group you created. It is recommended to create the first role with the name 'Root'. The role you have created with id 1 will always have all permissions.
  • Create a user with the group and role you just created.
  • Log in on /Users/login as the user created, go to /AclManager and click on Restore to default to create ACOs and AROs automatically.

Comment the uncommented

Comment $this->Auth->allow(); from initialize function and return true; from isAuthorized function on AppController.

public function initialize() {
    parent::initialize();
    ...
    
    // Only for ACL setup
    // $this->Auth->allow();
}

public function isAuthorized($user) {
    // Only for ACL setup
    // return true;
    
    ...
}

Enjoy!

Now you can start customizing your permissions and Develop your app. Do not forget to update the ACOs when creating new functions.

Changelog

v1.2

  • Updated version requirement to 1.* for latest ivanamat/cakephp3-aclmanager.
  • Updated version requirement to ~1.0 for latest cakephp/plugin-installer.

Author

Iván Amat on GitHub
www.ivanamat.es

cakephp3-app's People

Contributors

ivanamat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.