HERE BE DRAGONS: This project is very dead and published here only as a curiosity for people with morbid interests
PHP on Crutches is a web application framework for PHP with a focus on convention over configuration. It's loosely based on Ruby on Rails and clones like CakePHP.
- MVC-like structure with dispatcher, controllers, models and views
- Database-agnostic model implementation with validation
- ORM with ActiveRecord and lazily-evaluated querysets
- Internationalization with gettext and multi-language templates
- Modular cache store with support for Xcache, APC, and files
- Logger with colored output and optional MySQL query analysis
- Configuration system with environments
- Test framework based on SimpleTest
- Code coverage generator (needs Xdebug)
- Server launcher for lighttpd
- Interactive PHP console (needs rlwrap)
- PHP 5.2.3 or newer, with PDO and the necessary database drivers
- Debian or something similar helps (and is needed for some features)
It's only tested on Apache and lighttpd with MySQL and SQLite.
-
Use
config/application.php
for global settings -
Use
config/environments/*
for environment-specific settings -
See
lib/config.php
for all available settings and defaults -
You can define Rails-style routes in
config/routes.php
-
You can configure your database connections in
config/database.php
-
The included
script/server
should run lighttpd configured for URL rewriting.
(Note: serving files outside ofimages
,stylesheets
andjavascripts
doesn't work.)
Here are a few pointers to get started:
-
If your webserver is setup correctly (or you use
script/server
) you should see a welcome page with some information about your system. -
Use
script/generate
vor some (very) basic scaffolding. -
Create models in
app/models
, e.g. for the modelUser
you would use the fileapp/models/user.php
. The model can either extend from the baseModel
or fromActiveRecord
. -
Create controllers in
app/controllers
, e.g. for the path/foo
you would create aFooController
inapp/controllers/foo_controller.php
. The controller needs to extend fromApplicationController
. -
For each action, add a public method to the controller with the same name as the action. Further path parts will be used as arguments to this method, e.g. for the path
/foo/edit/1
you would create a methodedit($id)
. -
Inside the action, use
$this->set($key, $value)
to assign values to the view. -
Create views in
app/views/foo
, e.g. for the actionedit
you would create the fileapp/views/foo/edit.thtml
. This is a normal PHP file where you can display the variables assigned in the controller. -
Add generic helper functions in
app/helpers/application_helper.php
. -
Add controller-specific helper functions in
app/helpers
, e.g. for theFooController
you would createapp/helpers/foo_helper.php
.
For further details please refer to the source code...
PHP on Crutches is distributed under the MIT license