Download the PHP package sendy/modularizer without Composer
On this page you can find all versions of the php package sendy/modularizer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package modularizer
Laravel 4 Modularizer
https://github.com/sendyhalim/laravel-modularizer
This package is still in early development, but it is usable and already tested.
Modularizer is a Laravel 4 plugin. Basically it is an artisan command that creates module and auto validation repository based on given input. It is inspired by these amazing people:
Install
Add "sendy/modularizer": "dev-master"
to your composer.json then run composer update
in your terminal.
Add Sendy\Modularizer\ModularizerCommandServiceProvider
and Sendy\Modularizer\ModularizerModulesServiceProvider
respectively to app/config/app.php
service providers.
Sendy\Modularizer\ModularizerCommandServiceProvider
is for registering commands.Sendy\Modularizer\ModularizerModulesServiceProvider
is for registering active modules(registers route and view namespace of module).
Last, (with default config)include this to your composer.json for autoloading
Using it...
First make you need to publish the config, fire up your terminal and type
it will generate modularizer config app/config/packages/sendy/modularizer/module.php
inside the config, there's
base_path
is the path where your module will be created.base_directory
is the base directory inside base path, by default it will make module inapp/modules/Modules
. With this, it's easy to include composer autoloading namespace by usingModules
as base namespace.active
is an array of active modules, think of it as module registration.
Available Commands
Create a module:
arguments
- Module name
options
--path
base path to modules to be created, default toapp/modules
.--basedirectory
base directory of modules, default toModules
, with default config modules will be created inapp/modules/Modules
and base namespace will beModules
.
Prepare modularizer, make Core
for your modules
options
--path
base path to modules to be created, default toapp/modules
.--basedirectory
base directory of modules, default toModules
, with default configCore
will be created inapp/modules/Modules
and base namespace will beModules
.
Create repository
arguments
- Model name
- Module name
options
--path
base path to modules to be created, default toapp/modules
.--basedirectory
base directory of modules, default toModules
, with default config modules will be created inapp/modules/Modules
and base namespace will beModules
.--basenamespace
base namespace, defaultModules
.
Create migration for a module
This command takes input and call php artisan migrate:make
command with path edited to module path hence you need to specify your module name
arguments
- Migration name
- Module name
options
--path
path for migration file, with default config it will beapp/modules/ModuleName/database/migrations
.--basedirectory
base directory of modules, default toModules
--create
specify this if the migration is to create new table.(Same as laravel migration option)--table
specify this if the migration is to modify new table.(Same as laravel migration option)
Examples
Creating Admin
module
with default config it will create Admin module in app/modules/Modules
Admin views is registered with its namespace admin::view-file
, example I have a view file Admin/views/layout.blade.php
, to get it you need to use admin::layout
Modularizer also comes with autovalidation repository, first you need to publish Core
(I like to call it so, but you can configure whatever name you like)
with default config it will create Core
in app/modules/Modules
All repositories and interfaces that are created by modularizer will automatically extend BasicRepository(Reader/Writer) and its interface will automatically extend BasicRepository(Reader/Writer)Interfaces
Notice ValidatorInterface.php
, everytime we save(create/update) with a repository, we need to pass a class that implements ValidatorInterface
to the repository. First let's make a validator for model User
Now we need a UserRepository, with modularizer we can make it fast
the above command will make repository(read and write) for model User
inside Admin
module. 4 Files will be created for you
Admin/RepositoryInterfaces/Read/UserRepositoryReaderInterface
Admin/RepositoryInterfaces/Write/UserRepositoryWriterInterface
Admin/Repositories/Read/UserRepositoryReader
Admin/Repositories/Write/UserRepositoryWriter
The repository interfaces will be tied with user repositories
That's it! We can use the UserRepository
now