Download the PHP package shadowprince/autoparis without Composer
On this page you can find all versions of the php package shadowprince/autoparis. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shadowprince/autoparis
More information about shadowprince/autoparis
Files in shadowprince/autoparis
Package autoparis
Short Description Automated scheme creator & updater integrated and built for idiorm & paris. Currenlty works only with MySQL
License BSD
Homepage http://shadowprince.github.com/autoparis
Informations about the package autoparis
AutoParis
Autoparis is a library, that extends j4mie's paris ORM for automated scheme creation and keeping it up to date.
How to use it?
Installing
Autoparis can be simply installed by composer, actual install information you can found at page on packagist.
Requirements
- Model should extend \Autoparis\AutoModel and provide public ( non static ) method getFields(). It should return array of instances of \Autoparis\Field or classes extending it.
- public static $_field of every model should be setted up.
- You should provide lookup_models() function in bin/autoparis.php, that'll return array of models classes
- And you should properly configure idiorm when you start autoparis (you can get trough it simply including your project boostrap, that will call ORM::configure's)
Usage
Autoparis is a cli-tool, located in bin/autoparis.php. You can get help trough --help. Autoparis has behavior like django's tool. By default, autoparis will update all schemes for models returned by lookup_models() Like django, autoparis will not modify your tables if you dont provide --force option, because that action can damage data, so dont run it on production databases.
Documentation
There is documentation, that covers few topics that might be unclear and usefull.
Examples
// model class
class User extends \Autoparis\AutoModel {
public static $_table = 'users';
public function getFields() {
return [
new \Autoparis\Int("id", ["nn" => true]),
new \Autoparis\Varchar("username", 32),
new \Autoparis\Varchar("password"", 32),
new \Autoparis\DateTime("joined", ["default" => "now"])
];
}
// in autoparis.php
ORM::configure(...);
function lookup_models() {
return ["\User"];
}
$ ./autoparis.php
Processing \User...
Up to date.
mysql [db]> show columns from users;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id | int(11) | NO | | NULL | |
| username | varchar(32) | YES | | NULL | |
| password | varchar(32) | YES | | NULL | |
| joined | datetime | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+