Download the PHP package mothership-ec/cog-user without Composer

On this page you can find all versions of the php package mothership-ec/cog-user. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cog-user

User

The Message\User cogule provides a simple user and permission system.

Services

todo: list services defined here

Events

The following events are fired by this cogule. The event object is always an instance of Message\User\Event\Event.

Users

A user has the following properties:

And the usual metadata for creation and updating. There is no metadata for deletion because when a user is deleted they are hard deleted: they no longer exist in the database.

If your application or module needs to add more properties to a user, it is recommended to group these properties in a way that makes sense, and create a new model representing that group of properties. The Message\User\User object should remain a simple representation of basic user information.

For example, in an e-commerce module, address data might be stored for users. In this case, it would make sense to create a model representing a user's address, like so:

class UserAddress
{
    public $user;

    public $typeID;

    public $addressLines;
    public $town;
    public $postcode;
    public $countryID;
    public $stateID;
    public $telephone;
}

Groups

A user group is, of course, a simple way of grouping users. The Message\User cogule doesn't define any groups itself, but it provides groups functionality and a framework for any other cogule to define groups.

To define a group, first you need to create a class that implements Message\User\Group\GroupInterface:

<?php

namespace Message\MyModule;

use Message\User\Group;

class SuperAdmin implements Group\GroupInterface
{
    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'super-admin';
    }

    /**
     * {@inheritdoc}
     */
    public function getDisplayName()
    {
        return 'Super Administrators';
    }

    /**
     * {@inheritdoc}
     */
    public function getDescription()
    {
        return 'Users with access to everything!';
    }

    /**
     * {@inheritdoc}
     */
    public function registerPermissions(Group\Permissions $permissions)
    {
        // ...
    }
}

Then you just need to add it to the user.groups service definition, which is a collection of user groups available to the system. Any user group that is not added to this collection is not "known" to the system.

Ideally, groups should be added to the collection on the modules.load.success event. Add an event listener like this to your cogule's events bootstrap:

$dispatcher->addListener('modules.load.success', function() use ($services) {
    $services['user.groups']
        ->add(new Message\MyModule\SuperAdmin);
});

Permissions

A simple permissions system is included in this cogule that is built around user groups and route collections or routes.

Every group must implement the registerPermissions() method that is defined on the Message\User\Group\GroupInterface interface. The argument passed in to this method is an instance of Message\User\Group\Permissions for the appropriate group.

Within registerPermissions(), a set of permissions can be registered for the group. A group can be granted permission to any of the following:

Here's an example of all three:

public function registerPermissions(Permissions $permissions)
{
    // Grants the group access to all routes in the 'my.collection' route collection
    $permissions
        ->addRouteCollection('my.collection');

    // Grants the group access to the `homepage` and `secret.page` route
    $permissions
        ->addRoute('homepage')
        ->addRoute('secret.page');

    // Grants the group access to the `file.view` route only when the `type` parameter equals "image"
    $permissions
        ->addRoute('file.view', array('type' => 'image'));
}

Once any group defines a permission for a route or a route collection, that route or route collection becomes "protected", making it unavailable unless the current user is in a group that has access to the route collection or specific route.

If the current user does not the appropriate permissions to access a protected route, an Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException is thrown.

Controllers & Routes

todo: write about the controllers available and the routes, and how to use them in an app


All versions of cog-user with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
mothership-ec/cog Version ~4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mothership-ec/cog-user contains the following files

Loading the files please wait ....