Dachi Web Framework
Dachi is a PHP web framework., (*1)
Installation
-
Install Node.JS (for bower and grunt)
-
Install Composer (for back-end package management)
-
npm install -g bower (for front-end package management)
-
npm install -g grunt (for automation of tasks)
Existing Project
Linux/Mac: composer install && vendor/bin/dachi dachi:all, (*2)
Windows: composer install && vendor\bin\dachi dachi:all, (*3)
New Project
To create a new Dachi project just create a composer.json file with the following in:, (*4)
{
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"SampleClient\\SampleProject\\": "src/"
}
},
"require": {
"ouropencode/dachi": "^4.0"
}
}
You should replace SampleClient\\SampleProject\\ with the correct name-space for your project. However, the sample src/ code will fail once this is changed, so it is advised you change this AFTER you have fiddled with and removed the sample src/ code, (*5)
After creating this file, just run composer install. This will then download Dachi and all it's dependencies., (*6)
You should then run the following command to generate project files:, (*7)
Linux/Mac: vendor/bin/dachi dachi:create, (*8)
Windows: vendor\bin\dachi dachi:create, (*9)
Dachi and your project are now ready. You should now configure Dachi (see 'Configuration')., (*10)
Dachi provides a command line tool to help with development., (*11)
Refresh Everything
Although most of the commands can be run separately, it is often best to ensure all cache files and internal requirements are correct. You can run all of the required commands using:, (*12)
Linux/Mac: vendor/bin/dachi dachi:all, (*13)
Windows: vendor\bin\dachi dachi:all, (*14)
This will run the following commands:, (*15)
npm install
bower install
dachi:route
dachi:modules
dachi:config
grunt --no-color
Creating a project
After installation Dachi does nothing. If you are not using an existing project, you must first create a project using the CLI tool:, (*16)
Linux/Mac: vendor/bin/dachi dachi:create, (*17)
Windows: vendor\bin\dachi dachi:create, (*18)
Generating Routes
Before Dachi can route requests, routing information will need to be generated. This is done via the CLI tool:, (*19)
Linux/Mac: vendor/bin/dachi dachi:route, (*20)
Windows: vendor\bin\dachi dachi:route, (*21)
This will generate a cache/dachi.routes.json file that is used internally for routing requests. This command must be run again if url routing changes., (*22)
Generating Configuration
Dachi provides many JSON files for configuration. To speed up requests when deployed, these files must be concatenated into a single quick-to-load file. This is done via the CLI tool:, (*23)
Linux/Mac: vendor/bin/dachi dachi:route, (*24)
Windows: vendor\bin\dachi dachi:route, (*25)
This will generate a cache/dachi.config.json file that is used internally for configuration. This command must be run again if the configuration files are changed., (*26)
Dachi uses a system to provide features, such as shortcuts, to modules. Shortcuts allow you to use SampleModule:Model instead of SampleClient\SampleProject\SampleModule\Model in database and templating. This system may be used in future for providing other features to modules. You can generate the modules information file using the CLI:, (*27)
Linux/Mac: vendor/bin/dachi dachi:modules, (*28)
Windows: vendor\bin\dachi dachi:modules, (*29)
This will generate a cache/dachi.modules.json file that is used internally for setting up modules. This command must be run again if a module is added/removed or renamed., (*30)
Generating Documentation
Dachi is completely documented using ApiGen. Documentation can be generated using the CLI tool:, (*31)
Linux/Mac: vendor/bin/dachi dachi:document, (*32)
Windows: vendor\bin\dachi dachi:document, (*33)
This tool will generate documentation in a documentation folder. This documentation will include documentation for your project. It is advised all projects also use the ApiGen format. The tool can be passed the --internal argument, this will then generate documentation useful for debugging the Dachi core., (*34)
Configuration
Before you can deploy Dachi, you should confirm your configuration is correct. The default values are often insufficient., (*35)
Dachi Configuration
The core configuration files for Dachi are stored in the config directory. The config directory contains three folders, one for each environment:, (*36)
production
development
local
The three levels act as overrides. production settings will be used as the defaults, with development and local stacked onto them. This means you can omit configuration files you don't need to override. Detailed information regarding the configuration options can be found at http://this.doesnt.exist.yet., (*37)
At the very least you should confirm the dachi.json file is correct and the database.json file is correct., (*38)
If you change configuration, you must delete the cache/dachi.config.json file and run the dachi:config CLI command., (*39)
Apache Configuration
Dachi uses Apache at the core to redirect all URIs into the main index.php file. You should confirm that the RewriteBase is correctly set in the .htaccess file. (Other web servers can be used so long as they support PHP and you redirect all requests to src/index.php?dachi_uri=THE_URI_OMITTING_DOMAIN (i.e. src/index.php?dachi_uri=/samples/13/view), (*40)
Grunt Configuration
Grunt is now implemented and currently used for generating a concatenated bower css/js file. There is currently no support for per-project grunt files. Grunt is configured used files prefixed with grunt. in the standard 'Dachi Configuration' folders (see above)., (*41)
Reference Documents
Sublime Integration
Notes
- @route-render must be higher than @route-uri (i.e.
@route-uri /x/y @route-render /x is fine. @route-uri /x/y @route-render /z is bad, @route-uri /x/y @route-render /x/y/z is also bad)
- when called via @route-render, the request URI variables will be the initial requests variables (
@route-uri /x/:id/delete @route-render /x/:id will work, @route-uri /x/:cool_id/delete @route-render /x/:diff_id will not!)