rinvex/workshop

Generators for scaffolding Rinvex Cluster resources.


Keywords
laravel, generators, workshop, rinvex, scafollding
License
MIT

Documentation

Rinvex Workshop

Generators for scaffolding Rinvex Cluster resources.

Packagist License VersionEye Dependencies Scrutinizer Code Quality Code Climate StyleCI SensioLabs Insight

Table Of Contents

Installation

The best and easiest way to install this package is with Composer.

Prerequisites

"php": ">=5.5.9",
"rinvex/support": "1.0.*",
"illuminate/support": "5.1.*",
"illuminate/filesystem": "5.1.*",
"laravelcollective/html": "5.1.*"

Require Package

Open your application's composer.json file and add the following line to the require array:

"rinvex/workshop": "1.0.*"

Note: Make sure that after the required changes your composer.json file is valid by running composer validate.

Install Dependencies

On your terminal run composer install or composer update command according to your application's status to install the new requirements.

Note: Checkout Composer's Basic Usage documentation for further details.

Integration

Workshop is a Laravel package and it doesn't require any further steps after installation for integration. Proceed to the Usage section for an example.

Usage

In this section we'll show you how to make use of this package.

Generators

DataGrid Generator

The data grid generator can generate data grid view files accompanied with the js files required to initialize it and the help files and content blocks:

use Rinvex\Workshop\Generators\DataGridGenerator;

$generator = new DataGridGenerator('foo/bar', $app['files'], $app['html'], $app['form']);

$generator->create('post');

In addition to the first required $name argument, the create method can receive several optional arguments: $themeArea, $theme, $viewName, $columns, $model for maximum flexibility and control.

Executing the previous lines, will generate the following files and directories:

'-- resources
    |-- lang
    |   '-- en
    |       '-- posts
    |           '-- model.php
    |
    '-- themes
        '-- admin
            '-- default
                '-- packages
                    '-- foo
                        '-- bar
                            |-- assets
                            |   '-- posts
                            |       '-- js
                            |           '-- index.js
                            |
                            '-- views
                                '-- posts
                                    |-- content
                                    |   '-- help.md
                                    |
                                    |-- grid
                                    |   '-- index
                                    |       |-- filters.blade.php
                                    |       |-- no_filters.blade.php
                                    |       |-- no_results.blade.php
                                    |       |-- pagination.blade.php
                                    |       '-- results.blade.php
                                    |
                                    |-- help.blade.php
                                    '-- index.blade.php

Extension Generator

The extension generator can generate the core files and resources for an extension:

use Rinvex\Workshop\Generators\ExtensionGenerator;

$generator = new ExtensionGenerator('foo/bar', $app['files']);

$generator->create();
create()

The create method will generate the basic extension files and directories as follows:

|-- database
|   |-- migrations
|   |   '-- .gitkeep
|   '-- seeds
|       '-- .gitkeep
|
|-- composer.json
'-- extension.php
createModel()

The createModel method creates a new model with the given name:

$generator->createModel('post');

Generated model resides in the following location:

'-- src
    '-- Models
        '-- Post.php
createWidget()

The createWidget method creates a new widget with the given name:

$generator->createWidget('post');

Generated widget resides in the following location:

'-- src
    '-- Widgets
        '-- Post.php
createController()

The createController method creates a new controller with the given name:

$generator->createController('post');

// Create another new controller in different theme area, and pass fetched columns
$generator->createController('blog', 'frontend', ['name', 'description']);

In addition to the first required $name argument, the createController method can receive several optional arguments: $themeArea, $args for maximum flexibility and control.

Generated controller resides in the following location:

'-- src
    '-- Http
        '-- Controllers
            '-- PostsController.php
writeComposerFile()

The writeComposerFile method writes the composer.json file:

$generator->writeComposerFile();
writeExtensionFile()

The writeExtensionFile method writes the extension.php file:

$generator->writeExtensionFile();
writeServiceProvider()

The writeServiceProvider method writes the service provider and append it to the extension.php file:

$generator->writeServiceProvider('post');
writeRoutes()

The writeRoutes method writes the routes section to the extension.php file:

$generator->writeRoutes('post', true, true);

In addition to the first required $resource argument, the writeRoutes method can receive several optional arguments: $adminRoutes, $frontendRoutes to control whether to write admin and/or frontend routes or not.

writePermissions()

The writePermissions method writes the permissions section to the extension.php file:

$generator->writePermissions('post');
writeMenus()

The writeMenus method writes the routes section to the extension.php file:

$generator->writeMenus('post');
writeLang()

The writeLang method writes the language files (common.php, message.php, permissions.php):

$generator->writeLang('post');

Generated language files resides in the following location:

'-- resources
    '-- lang
        '-- en
            '-- posts
                |-- common.php
                |-- message.php
                '-- permissions.php

Note: For the writeServiceProvider, writeRoutes, writePermissions, and writeMenus methods, if you have not already created extension.php file in your extension, you have to do so first through writeExtensionFile() method, otherwise an exception will be thrown.

Extension Theme Generator

The extension theme generator can generate theme directories:

use Rinvex\Workshop\Generators\ExtensionThemeGenerator;

$generator = new ExtensionThemeGenerator('foo/bar', $app['files']);

$generator->create('admin');

In addition to the first required $themeArea argument, the create method can receive another optional argument: $theme to specify custom theme if desired.

The create method will generate the following files and directories:

'-- resources
    '-- themes
        '-- admin
            '-- default
                '-- packages
                    '-- foo
                        '-- bar
                            |-- assets
                            |   |-- css
                            |   |   '-- style.css
                            |   '-- js
                            |       '-- script.js
                            |
                            '-- views
                                '-- .gitkeep

Form Generator

The form generator can generate form view files:

use Rinvex\Workshop\Generators\FormGenerator;

$generator = new FormGenerator('foo/bar', $app['files']);

$generator->create('post');

In addition to the first required $model argument, the create method can receive several optional arguments: $columns, $view for maximum flexibility and control.

The create method will generate the following files and directories:

'-- resources
    |-- lang
    |   '-- en
    |       '-- posts
    |           '-- model.php
    |
    '-- themes
        '-- admin
            '-- default
                '-- packages
                    '-- foo
                        '-- bar
                            '-- views
                                '-- posts
                                    '-- form.blade.php

Migrations Generator

The migrations generator can generate migrations and seeders:

use Rinvex\Workshop\Generators\MigrationsGenerator;

$generator = new MigrationsGenerator('foo/bar', $app['files']);

$generator->create('posts');

In addition to the first required $table argument, the create method can receive several optional arguments: $columns, $increments, $timestamps for maximum flexibility and control.

The create method will generate the following files and directories:

'-- database
    '-- migrations
        '-- 2016_04_03_175031_alter_posts_table.php

Seeds could be created in the same way as well:

use Rinvex\Workshop\Generators\MigrationsGenerator;

$generator = new MigrationsGenerator('foo/bar', $app['files']);

// Insert 33 record into `posts` table (Both arguments are optional)
$generator->seeder(33, 'posts');

The seeder method will generate the following files and directories:

'-- database
    '-- seeds
        '-- PostsTableSeeder.php

Note: If you have not already created database directory in your extension root, you have to do so first manually or by following the Extension Generator step, otherwise an exception will be thrown.

Repository Generator

The repository generator can generate repositories and handlers that are used on the repositories:

use Rinvex\Workshop\Generators\RepositoryGenerator;

$generator = new RepositoryGenerator('foo/bar', $app['files']);

// Create all repository related files and directories
$generator->create('post');

// Write only repository files and directories
$generator->writeRepository('post');

// Write only event handler files and directories
$generator->writeEventHandler('post');

// Write only data handler files and directories
$generator->writeDataHandler('post');

// Write only validator files and directories
$generator->writeValidator('post');
create()

The create method will generate all repository related files and directories:

'-- src
    |-- Handlers
    |   '-- Post
    |       |-- PostDataHandler.php
    |       |-- PostDataHandlerInterface.php
    |       |-- PostEventHandler.php
    |       '-- PostEventHandlerInterface.php
    |
    |-- Repositories
    |   '-- Post
    |       |-- PostRepository.php
    |       '-- PostRepositoryInterface.php
    |
    '-- Validators
        '-- Post
            |-- PostValidator.php
            '-- PostValidatorInterface.php
writeRepository()

The writeRepository method will write only repository files and directories:

'-- src
    '-- Repositories
        '-- Post
            |-- PostRepository.php
            '-- PostRepositoryInterface.php
writeEventHandler()

The writeEventHandler method will write only event handler files and directories:

'-- src
    '-- Handlers
        '-- Post
            |-- PostEventHandler.php
            '-- PostEventHandlerInterface.php
writeDataHandler()

The writeDataHandler method will write only data handler files and directories:

'-- src
    '-- Handlers
        '-- Post
            |-- PostDataHandler.php
            '-- PostDataHandlerInterface.php
writeValidator()

The writeValidator method will write only validator files and directories:

'-- src
    '-- Validators
        '-- Post
            |-- PostValidator.php
            '-- PostValidatorInterface.php

Stubs

Stub files are located under src/resources/stubs/*, you can override the default stubs by setting a stubs directory using Rinvex\Workshop\Generators\AbstractGenerator::setStubsDir($dir) and just override the stub files you need changed on that directory.

Notes:

Changelog

Refer to the Changelog for a full history of the project.

Support

The following support channels can be used for contact.

Contributing & Protocols

Thank you for considering contributing to this project! The contribution guide can be found in CONTRIBUTING.md.

Bug reports, feature requests, and pull requests are very welcome.

Important Credits Notice

This work was inspired by and/or forked from the latest BSD release of Cartalyst (R) packages.

Original credits go to the Cartalyst team with much love and appreciation. Public Notice

Security Vulnerabilities

If you discover a security vulnerability within this project, please send an e-mail to help@rinvex.com. All security vulnerabilities will be promptly addressed.

License

This software is released under The MIT License (MIT).

(c) 2015-2016 Rinvex LLC, Some rights reserved.