Skip to content

alphamarket/zg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zg

Zinux Generator Tool

This is a tool designed to create, manipulate zinux projects. Zinux generator tool is an efficient appliction designed to make use of zinux project even easier than it is, and also makes you develop more, in a short time.

From now on we will refer to Zinux Generator Tool by zg.

Topics

Requirements

  • PHP version 5.3.10 or greater
  • Zinux Project 3.0.0 or greater

Installation

There is a zinux installer shell script, it will automatically download and configure your system to use zinux project freely in your system.
It also installs zinux generator tool which is an handy tool to create, manipulate and provides solid security for your zinux project, for more information see Zinux Generator Tool.

You will need to have Git installed before using zinux installer.

For installation just download the zinux installer and save it at anywhere, and run the following command bash /path/to/your/zinux/installer it will do the reset.

Windows Users

For technical reasons zinux generator does not support Windows!! You just have to clone and use the framework manually.
We are sorry about this....

Some advise for PHP developers, you cannot become a professional PHP developer and develop a full scale PHP application within windows, you just cannot!! so maybe it is time to move your PHP developments on linux.

Command Types

The zg uses very simple and flexible command lines. Except Security command line which is an sensitive command all other commands has aliases which is the short form of original command. A list of available commands and their details are as follow:

Version

Title
Shows Version.


Description
Show both Zinux's and Zinux Generator's versions.
# Command
zg --version
# Help
zg -h --version

Help

Title
Prints help content.


Description
Prints help content. * It can be general help, which will print all commands help content. * It can be specific, which will print only the help content of target command.
# Command
zg -h ($command) (--heads)
# Alias
zg -h ($command_alias) (--heads)
# Help
zg -h -h

Optionals
* $command : print a specific command's help content. * --heads : if you pass this argument it will only print valid command lines under `$command` command line.
Default Values
* $command : If you don't pass `$command` it will print all commands' help content.
Notes
* `$command` should be a valid command in `zg` command list.
Examples
```PHP # prints all commands' help content zg # OR using aliases : zg -h ``` ```PHP # prints 'zg new'command's help content zg -h new # OR using aliases : zg -h n ``` Or you can be more specific, like: ```PHP # prints 'zg new action' command's help content zg -h new action # OR using aliases : zg -h n a ```
New -- New Project -- Title
Create new project. Description
This command will creates new project and its initial files and directories are: * application * appBootstrap.php * appRoutes.php * modules/defaultModule * controller * indexController.php * views/layout * defaultLayout.phtml * views/view/index * indexView.phtml * defaultBootstrap.php * public_html * index.php * .htaccess * [zinux](https://github.com/dariushha/zinux) framework
# Command
zg new project $project_name (--empty)
# Alias
zg n $project_name (--empty)
# Help
zg -h n p

Optionals
* --empty : By passing this option it will create an empty project without any modules or application directory.
Notes
> In entire zg commands [spectial characters](http://en.wikipedia.org/wiki/Special_characters) in arguments will converted to '`_`' character.
Examples
```PHP # creates new project direcroty named 'test zg new project test # or using aliases: zg n test ```
New Module -- Title
Create new module.
Description
This command will creates new module for project and its initial files and directories are: * modules/MODULE_NAME * controller * indexController.php * views/layout * MODULE_NAMELayout.phtml * views/view/index * indexView.phtml * defaultBootstrap.php
# Command
zg new module $module_name
# Alias
zg n module $module_name
# Help
zg -h n module

Notes

The Module postfix is not needed at end of $module_name.


Examples
```PHP # creates new module named 'admin' zg new module admin # or using aliases: zg n module admin ``` ```PHP # creates new module named 'ssl' zg new module ssl # or using aliases: zg n module ssl ```
New Controller -- Title
Create new controller.
Description
Creates new controller in a module and its initial files and directories are: * modules/MODULE_NAME * controller * CONTROLLER_NAMEController.php * views/view/CONTROLLER_NAME * indexView.phtml
# Command
zg new controller $controller_name ($module_name)
# Alias
zg n c $controller_name ($module_name)
# Help
zg -h n c

Optionals
* $module_name : The name of target module that we want to create the contoller in it.
Default Values
* $module_name : defaultModule * If no module name supplied by default defaultModule will be targeted.

Notes

The Module and Controller postfixes are not needed at end of $module_name and $controller_name names.


Examples
```PHP # creates new contoller named 'auth' in 'defaultModule' zg new controller auth # or more specific: zg new controller authController defaultModule # or using aliases: zg n c auth ``` ```PHP # creates new contoller named 'comments' in 'userModule' zg new controller comments user # or more specific: zg new controller commentsController userModule # or using aliases: zg n c comment user ```
New Action -- Title
Create new action function.
Description
Creates new action function in any desired, controller and module.
# Command
zg new action $action_name ($controller_name) ($module_name)
# Alias
zg n a $action_name ($controller_name) ($module_name)
# Help
zg -h n a

Optionals
* $controller_name : The name of target controller that we want to create the action in it. * $module_name : The name of target module that contains `$controller_name`.
Default Values
* $controller_name : indexController * $module_name : defaultModule
Notes
> The `Module`,`Controller`,`Action` postfixes are not needed at end of `$module_name`, `$controller_name` and `$action_name` names.
Examples
```PHP # creates new action named 'help' in 'indexController', 'defaultModule' zg new action help # or using aliases: zg n a help ``` ```PHP # creates new action named 'login' in 'authController', 'sslModule' zg new action login auth ssl # or using aliases: zg n a login auth ssl ```
New View -- Title
Create new view.
Description
Creates new view related to a controller in any desired module.
# Command
zg new view $view_name ($controller_name) ($module_name)
# Alias
zg n a $view_name ($controller_name) ($module_name)
# Help
zg -h n v

Optionals
* $controller_name : The name of target controller that we want to relate the view with it. * $module_name : The name of target module that contains `$controller_name`.
Default Values
* $controller_name : indexController * $module_name : defaultModule
Notes
> The `Module`,`Controller`,`View` postfixes are not needed at end of `$module_name`, `$controller_name` and `$view_name` names.
Examples
```PHP # creates new view named 'help2' in 'indexController', 'defaultModule' zg new view help2 # or using aliases: zg n v help2 ``` ```PHP # creates new view named 'login2' in 'authController', 'sslModule' zg new view login2 auth ssl # or using aliases: zg n v login2 auth ssl ```
New Layout -- Title
Create new layout.
Description
Creates new layout in a module.
# Command
zg new layout $layout_name ($module_name)
# Alias
zg n l $layout_name ($module_name)
# Help
zg -h n l

Optionals
* $module_name : The name of target module that we want to create the contoller in it.
Default Values
* $module_name : defaultModule * If no module name supplied by default defaultModule will be targeted.

Notes

The Module and Layout postfixes are not needed at end of $module_name and $layout_name names.


Examples
```PHP # creates new layout named 'print' in 'defaultModule' zg new layout print # or using aliases: zg n l print ``` ```PHP # creates new layout named 'dark' in 'userModule' zg new layout dark user # or using aliases: zg n l dark user ```
New Model -- Title
Create new model.
Description
Creates new model in a module.
# Command
zg new model $model_name ($module_name)
# Alias
zg n m $model_name ($module_name)
# Help
zg -h n m

Optionals
* $module_name : The name of target module that we want to create the contoller in it.
Default Values
* $module_name : defaultModule * If no module name supplied by default defaultModule will be targeted.

Notes

For free uses of models there is no naming convention in models, i.e in layouts when you execute the zg new layout dark it will create a layout named darkLayout with a Layout post-appended name.
In models there is no such post-appending in names, so for example if you execute the zg new model user it will create a model in defaultModule named exactly as you type i.e user and if you execute zg new model userModel it will exactly creates a model named userModel, etc.


> The `Module` postfix is not needed at end of `$module_name`.
Examples
```PHP # creates new model named 'user' in 'defaultModule' zg new model user # or using aliases: zg n m user ``` ```PHP # creates new model named 'adminModel' in 'userModule' zg new model adminModel user # or using aliases: zg n m adminModel user ```
New Helper -- Title
Create new heler.
Description
Creates new helper in a module.
# Command
zg new helper $helper_name ($module_name)
# Alias
zg n h $helper_name ($module_name)
# Help
zg -h n h

Optionals
* $module_name : The name of target module that we want to create the contoller in it.
Default Values
* $module_name : defaultModule * If no module name supplied by default defaultModule will be targeted.

Notes

The Module and Helper postfixes are not needed at end of $module_name and $helper_name.


Examples
```PHP # creates new helper named 'generics' in 'defaultModule' zg new helper generics # or using aliases: zg n h generics ``` ```PHP # creates new helper named 'validators' in 'userModule' zg new helper validators user # or using aliases: zg n h validators user ``` New Application -- New Application Bootstrap -- Title
Create new application bootstrap for project.
Description
This command will creates new application bootstrap under `PROJECT-ROOT/application` directory.
# Command
zg new application boostrap $bootstrap_name
# Alias
zg n app b $bootstrap_name
# Help
zg -h n app b

Notes

The Bootstrap postfix is not needed at end of $bootstrap_name.


Examples
```PHP # creates new application bootstrap named 'db' zg new application bootstrap db # or using aliases: zg n app b db ``` ```PHP # creates new application bootstrap named 'ssl' zg new application bootstrap ssl # or using aliases: zg n app b ssl ```
New Application Routes -- Title
Create new application routes for project.
Description
This command will creates new application routes under `PROJECT-ROOT/application` directory.
# Command
zg new application routes $routes_name
# Alias
zg n app r $routes_name
# Help
zg -h n app r

Notes

The Routes postfix is not needed at end of $routes_name.

Examples

# creates new application routes named 'comment'
zg new application routes comment
# or using aliases: 
zg n app r comments
# creates new application routes named 'ssl'
zg new application routes ssl
# or using aliases: 
zg n app r ssl

Remove -- Remove Module -- Title
Removes an existed module.
Description
This command will Remove an existed module from project.
# Command
zg remove module $module_name
# Alias
zg r module $module_name
# Help
zg -h r module

Notes

The Module postfix is not needed at end of $module_name.


Examples
```PHP # removes an existed module named 'admin' zg remove module admin # or using aliases: zg r module admin ``` ```PHP # removes an existed module named 'ssl' zg remove module ssl # or using aliases: zg r module ssl ```
Remove Controller -- Title
Removes an existed controller.
Description
Removes an existed controller from module.
# Command
zg remove controller $controller_name ($module_name)
# Alias
zg r c $controller_name ($module_name)
# Help
zg -h r c

Optionals
* $module_name : The name of target module that we want to remove the contoller from it.
Default Values
* $module_name : defaultModule * If no module name supplied by default defaultModule will be targeted.

Notes

The Module and Controller postfixes are not needed at end of $module_name and $controller_name names.


Examples
```PHP # removes an existed contoller named 'auth' from 'defaultModule' zg remove controller auth # or more specific: zg remove controller authController defaultModule # or using aliases: zg r c auth ``` ```PHP # removes an existed contoller named 'comments' from 'userModule' zg remove controller comments user # or more specific: zg remove controller commentsController userModule # or using aliases: zg r c comment user ```
Remove Action -- Title
Removes an existed action function.
Description
Removes an existed action function from any desired, controller and module.
# Command
zg remove action $action_name ($controller_name) ($module_name)
# Alias
zg r a $action_name ($controller_name) ($module_name)
# Help
zg -h r a

Optionals
* $controller_name : The name of target controller that we want to remove the action from it. * $module_name : The name of target module that contains `$controller_name`.
Default Values
* $controller_name : indexController * $module_name : defaultModule
Notes
> The `Module`,`Controller`,`Action` postfixes are not needed at end of `$module_name`, `$controller_name` and `$action_name` names.
Examples
```PHP # removes an existed action named 'help' from 'indexController', 'defaultModule' zg remove action help # or using aliases: zg r a help ``` ```PHP # removes an existed action named 'login' from 'authController', 'sslModule' zg remove action login auth ssl # or using aliases: zg r a login auth ssl ```
Remove View -- Title
Removes an existed view.
Description
Removes an existed view related to a controller from any desired module.
# Command
zg remove view $view_name ($controller_name) ($module_name)
# Alias
zg r a $view_name ($controller_name) ($module_name)
# Help
zg -h r v

Optionals
* $controller_name : The name of target controller that we want to relate the view with it. * $module_name : The name of target module that contains `$controller_name`.
Default Values
* $controller_name : indexController * $module_name : defaultModule
Notes
> The `Module`,`Controller`,`View` postfixes are not needed at end of `$module_name`, `$controller_name` and `$view_name` names.
Examples
```PHP # removes an existed view named 'help2' from 'indexController', 'defaultModule' zg remove view help2 # or using aliases: zg r v help2 ``` ```PHP # removes an existed view named 'login2' from 'authController', 'sslModule' zg remove view login2 auth ssl # or using aliases: zg r v login2 auth ssl ```
Remove Layout -- Title
Removes an existed layout.
Description
Removes an existed layout from module.
# Command
zg remove layout $layout_name ($module_name)
# Alias
zg r l $layout_name ($module_name)
# Help
zg -h r l

Optionals
* $module_name : The name of target module that we want to remove the contoller from it.
Default Values
* $module_name : defaultModule * If no module name supplied by default defaultModule will be targeted.

Notes

The Module and Layout postfixes are not needed at end of $module_name and $layout_name names.


Examples
```PHP # removes an existed layout named 'print' from 'defaultModule' zg remove layout print # or using aliases: zg r l print ``` ```PHP # removes an existed layout named 'dark' from 'userModule' zg remove layout dark user # or using aliases: zg r l dark user ```
Remove Model -- Title
Removes an existed model.
Description
Removes an existed model from a module.
# Command
zg remove model $model_name ($module_name)
# Alias
zg r m $model_name ($module_name)
# Help
zg -h r m

Optionals
* $module_name : The name of target module that we want to remove the contoller from it.
Default Values
* $module_name : defaultModule * If no module name supplied by default defaultModule will be targeted.

Notes

For free uses of models there is no naming convention in models, i.e in layouts when you execute the zg remove layout dark it will remove a layout named darkLayout with a Layout post-appended name.
In models there is no such post-appending in names, so for example if you execute the zg remove model user it will remove a model in defaultModule named exactly as you type i.e user and if you execute zg remove model userModel it will exactly remove a model named userModel, etc.


> The `Module` postfix is not needed at end of `$module_name`.
Examples
```PHP # removes an existed model named 'user' from 'defaultModule' zg remove model user # or using aliases: zg r m user ``` ```PHP # removes an existed model named 'adminModel' from 'userModule' zg remove model adminModel user # or using aliases: zg r m adminModel user ```
Remove Helper -- Title
Removes an existed heler.
Description
Removes an existed helper from a module.
# Command
zg remove helper $helper_name ($module_name)
# Alias
zg r h $helper_name ($module_name)
# Help
zg -h r h

Optionals
* $module_name : The name of target module that we want to remove the contoller from it.
Default Values
* $module_name : defaultModule * If no module name supplied by default defaultModule will be targeted.

Notes

The Module and Helper postfixes are not needed at end of $module_name and $helper_name.


Examples
```PHP # removes an existed helper named 'generics' from 'defaultModule' zg remove helper generics # or using aliases: zg r h generics ``` ```PHP # removes an existed helper named 'validators' from 'userModule' zg remove helper validators user # or using aliases: zg r h validators user ``` Remove Application -- Remove Application Bootstrap -- Title
Removes an existed application bootstrap for project.
Description
This command will Removes an existed application bootstrap from `PROJECT-ROOT/application` directory.
# Command
zg remove application boostrap $bootstrap_name
# Alias
zg r app b $bootstrap_name
# Help
zg -h r app b

Notes

The Bootstrap postfix is not needed at end of $bootstrap_name.


Examples
```PHP # removes an existed application bootstrap named 'db' zg remove application bootstrap db # or using aliases: zg r app b db ``` ```PHP # removes an existed application bootstrap named 'ssl' zg remove application bootstrap ssl # or using aliases: zg r app b ssl ```
Remove Application Routes -- Title
Removes an existed application routes for project.
Description
This command will Removes an existed application routes from `PROJECT-ROOT/application` directory.
# Command
zg remove application routes $routes_name
# Alias
zg r app r $routes_name
# Help
zg -h r app r

Notes

The Routes postfix is not needed at end of $routes_name.

Examples

# removes an existed application routes named 'comment'
zg remove application routes comment
# or using aliases: 
zg r app r comments
# removes an existed application routes named 'ssl'
zg remove application routes ssl
# or using aliases: 
zg r app r ssl

Build

Title
Re-build zg config file.


Description
Sometimes happen you manipulate your project entities manually instead of using zg, i.e you may add a controller named `fooController` manually in `defaultController` and next time you may want to a new action named `barAction` to `fooController`, but since `fooController` created manually it doesn't exist in zg manifest list, so it won't recognize `fooController` and an error will raise like: ``` # output result of : # zg n a bar foo

Zinux Generator(vX.X.X) by Dariush Hasanpoor [b.g.dariush@gmail.com] 2013 [ Error occured ] Controller 'defaultModule/fooController' does not exist in zg manifest! Try 'zg build' command!

In such cases <i>zg</i> provided a simple solution and that is `zg build` command.<br />
It will build up <i>zg</i> manifest list from scratch to top, any [zinux entity](https://github.com/dariushha/zinux#mvc-entities)
will be re-registered again, including in our example case `fooController` which made manually.<br />
In our example case after `zg build` you are good to go with `zg n a bar foo`.

> There is an other usecase of `zg build` options an is that when you have lost or corrupted your <i>zg</i>
config files, this command will be useful. 

<hr />

```PHP
# Command
zg build ( -m ) ( -a ) ( -p )
# Alias
zg b ( -m ) ( -a ) ( -p )
# Help
zg -h b

Optionals
* -m : `-m /app/modules/path` * -a : `-a /app/application/folder/path` * -p : `-p /app/project/path`
Default Values
* -m : modules * -a : application * -p : .(Current Directory)
Notes
> In many normal cases you don't have to enter any of `zg build`'s options at all, as long as you lauch `zg build` in any project's root folder it will built up the zg manifest file.
Examples
```PHP # builds a zg manifest under current folder # note : we are in /path/to/PROJECT-ROOT when we are doing this zg build # or using aliases: zg b ``` ```PHP # builds a zg manifest for an application zg build -p "/path/to/target/app" -m "/relative/path/from/app/root/to/modules/" -a "/relative/path/to/application" # or using aliases: zg b -p "/path/to/target/app" -m "/relative/path/from/app/root/to/modules/" -a "/relative/path/to/application" ```

Config

Title
Configure zinux generator.


Description
Configure zinux generator for current project with given options.
# Command
zg config $options
# Alias
zg c $options
# Help
zg -h c

Notes
As i am wrting this document, there are only 2 options available for configuration: * -show-parents : Skip parent property in 'zg status' command. * +show-parents : Do not skip parent property in 'zg status' command.
Examples
```PHP zg config +show-parents # or using aliases: zg c -show-parents ```
Security -- Sometimes you need to send your PHP project or carray it with yourself but don't want to expose your project codes accidentally to public access, The zg come up with an solution, with zg you can encrypt or decrypt your project's files with any key you want.

Since the encryption/decryption are sensitive operations the zg didn't come up with aliases for this operations, to prevent un-wanted mistakes.

Encryption

Title
Encrypt your project.


Description
This command will encrypt all of your project's files except the zinux project under your project, with is ofcourse a public project.
Command
```PHP # Command zg security encrypt $encryption_key (-i #) ``` ```PHP # Help zg -h security encrypt ```
Optionals
* -i : Number of encryption iterations. This should be greater than 0.
Default Values
* -i : 1
Notes
> Be careful with command if you make mistake it is possible to blow up your project.
> When you encrypt your project, you cannot lost your '.zg' folder and its content. The project without its '.zg' will be too risky to encrypt!
> This command will encrypt your entire project except the 'zinux' folder. Which obviously is a public project!
> If you ever forger your $encryption_key, your project will be lost for good. So make sure you pass a easy to remember but hard to guess crypt key.
> If your $encryption_key is a multiline key put it between quotation marks!
Examples
```PHP # This will encrypt your project with a key the for 1 time zg security encrypt "Some multi-line KEY to 3nCRypT" ``` ```PHP # This will encrypt your project with a key the for 20 times zg security encrypt "Some single-line KEY BUt with iteration value" -i 20 ```
Decryption -- Title
Decrypt your project.
Description
This command will decrypt your project's encrypted files, the files that registered as encrypted in `zg security encrypt` command.
Command
```PHP # Command zg security decrypt $decryption_key (-i #) ``` ```PHP # Help zg -h security encrypt ```
Optionals
* -i : Number of decryption iterations. This should be greater than 0.
Default Values
* -i : 1
Notes
> Be careful with command if you make mistake it is possible to blow up your project.
> For decryption you have to pass exact key value and exact iteration number to get right decrypted codes.
> This command will decrypt your entire project which encrypted by 'zg security encrypt' command!!
> If your $decryption_key is a multiline key put it between quotation marks!
Examples
```PHP # This will decrypt your project with key same as encryption key the for 1 time zg security decrypt "Some multi-line KEY to 3nCRypT" ``` ```PHP # This will encrypt your project with key same as encryption key the for 20 times zg security encrypt "Some single-line KEY BUt with iteration value" -i 20 ```
Cryption Cache -- Title
Cryption cache operator.
Description
Provides operations on cryption cache.
```PHP # Command zg security cache (--clear|--reset) ``` ```PHP # Help zg -h security cache ```
Optionals
* --clear : Clears all cryption cached data and files. * --reset : Reset files to before previous DEcryption operation. With this option zg will undo LAST `zg security decryption` command's effects!
Details
> You cannot clear cryption cache while project flaged as encrypted.
Notes
> This command provides fail-safe for `zg security decryption` lets assume your have passed a wrong cryption key and you forced `zg security decryption` to decrypt the project while the key is wrong!!!
What happens then? you project's codes will blow-up! you will lost your code files!!
In above cases you case do `zg security cache --reset` command to undo LAST `zg security decryption` command's effects!!
> `zg security cache --reset` will undo the last `zg security decryption` command's effects!
Examples
```PHP # undo the LAST `zg security decryption` command's effects zg security --reset ``` ```PHP # After decrypting the project, clears the cache data and files zg security --cache ```
Status -- Title
Show project status.
Description
This command will output zg's report from project status.

```PHP # Command zg status (+p) (+d : #) ($section_name) ``` ```PHP # Alias zg s (+p) (+d : #) ($section_name)s ``` ```PHP # Help zg -h s ```
Optionals
* +p : Show items parent detail in structure tree. * +d : The depth # that recursion should proceed to. * $section_name : Narrow down your explore items by passing its path from root to target section name. e.g 'zg status modules collection defaultmodule':.Will show the details about defaultmodule!
Default Values
* $section_name : By default this command will show the entire status object. * +d : 5
Examples
```PHP # print project's entire status report zg status # or using aliases: zg s ``` ```PHP # print any reports zg has on default module in the project zg status modules collection defaultmodule # or using aliases: zg s modules collection defaultmodule ```
Update -- Title
Update zinux framework
Description
Update zinux framework with its online repository.
```PHP # Command zg update ( $branch_name ) (--all) (--cache | --simulate | --verbose) ``` ```PHP # Alias zg u ( $branch_name ) (--all) (--cache | --simulate | --verbose) ``` ```PHP # Help zg -h u ```
Optionals
* $branch_name
Default Values
* $branch_name : master
Notes
> WARNING: This command will `stash` any local changes before updating branches. Be aware of this!
Examples
```PHP # updated project's module's master branches zg update # or using aliases: zg u ``` ```PHP # simulate updating project's module's master branches # no change will be apply zg update --simulate # or using aliases: zg u --simulate ``` ```PHP # updates project's module's all branches zg update --all # or using aliases: zg u --all ``` ```PHP # updates installed zinux framework's cache's module # if you update your cached zinux, from then on every # project you create will be updated zg update --cache # or using aliases: zg u --cache ```