{"id":15345481,"url":"https://github.com/akrabat/akrabatzf","last_synced_at":"2025-03-17T06:08:05.090Z","repository":{"id":852252,"uuid":"582540","full_name":"akrabat/AkrabatZF","owner":"akrabat","description":"Akrabat_Db_Schema_Manager and a DatabaseSchemaProvider for Zend_Tool","archived":false,"fork":false,"pushed_at":"2014-03-06T21:01:24.000Z","size":220,"stargazers_count":96,"open_issues_count":3,"forks_count":23,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-04T08:07:51.032Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://akrabat.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akrabat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-03-27T19:55:51.000Z","updated_at":"2025-02-24T06:59:35.000Z","dependencies_parsed_at":"2022-07-25T22:02:36.350Z","dependency_job_id":null,"html_url":"https://github.com/akrabat/AkrabatZF","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akrabat%2FAkrabatZF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akrabat%2FAkrabatZF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akrabat%2FAkrabatZF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akrabat%2FAkrabatZF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akrabat","download_url":"https://codeload.github.com/akrabat/AkrabatZF/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243982177,"owners_count":20378604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T11:13:35.932Z","updated_at":"2025-03-17T06:08:05.072Z","avatar_url":"https://github.com/akrabat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Akrabat ZF library\n\nSee [Akrabat_Db_Schema_Manager: Zend Framework database migrations](http://akrabat.com/zend-framework/akrabat_db_schema_manager-zend-framework-database-migrations/) for full details. This code is licensed under the [New-BSD license](http://akrabat.com/license/new_bsd/).\n\nAkrabat_Db_Schema_Manager is a tool for use with ZF1. If you need a standalone tool, then have a look at [South for the Winter](https://github.com/startupdevs/sftw).\n\n\n## ZF1:\n\nTo get the Zend_Tool provider working:\n\n1. Place a copy of ZF1 in `/usr/local/include/zf1/`, so that the Zend folder is in `zf1/library/Zend`\n2. Update your `~/.bash_profile` to set up an alias to the zf.sh script\n\n        alias zf='export ZF_CONFIG_FILE=~/.zf.ini; /usr/local/include/zf1/bin/zf.sh'\n    \n   Restart your terminal or `source ~/.bash_profile`\n3. If you haven't already done so, setup the storage directory and config file:\n    \n        zf --setup storage-directory\n        zf --setup config-file\n        \n4. Place a copy of the Akrabat Tools in `/usr/local/include/Akrabat`:\n        \n        cd /usr/local/include\n        git clone http://github.com/akrabat/Akrabat.git\n        \n5. Edit the created `~/.zf.ini`. Change path so that it includes ZF1 and Akrabat/library, allow for auotoloading Akrabat and set up the provider:\n    \n        php.include_path = \"/usr/local/include/zf1/library:/usr/local/include/Akrabat/library/\"\n        autoloadernamespaces.0 = \"Akrabat_\"\n        basicloader.classes.0 = \"Akrabat_Tool_DatabaseSchemaProvider\"\n\n6. `zf` should provide a help screen with the `DatabaseSchema` provider at the bottom.\n\n### Akrabat_Db_Schema_Manager\n\n1. Create scripts/migrations folder in your ZF application\n2. Create migration files within migrations with the file name format of nnn-Xxxx.php. e.g. 001-Users.php\n    where:  \n       nnn =\u003e any number. The lower numbered files are executed first  \n       Xxx =\u003e any name. This is the class name within the file.\n       \n \tIn up(), database changes are applied, in down(), changes are reverted. If changes cannot be reverted, then down() should throw a Akrabat_Db_Schema_Exception.\n   \n3. Create a class in your migrations file. Example for 001-Users.php:\n    \n        class Users extends Akrabat_Db_Schema_AbstractChange \n        {\n            function up()\n            {\n                $tableName = $this-\u003e_tablePrefix . 'users';\n                $sql = \"\n                    CREATE TABLE IF NOT EXISTS $tableName (\n                      id int(11) NOT NULL AUTO_INCREMENT,\n                      username varchar(50) NOT NULL,\n                      password varchar(75) NOT NULL,\n                      roles varchar(200) NOT NULL DEFAULT 'user',\n                      PRIMARY KEY (id)\n                    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\";\n                $this-\u003e_db-\u003equery($sql);\n        \n                $data = array();\n                $data['username'] = 'admin';\n                $data['password'] = sha1('password');\n                $data['roles'] = 'user,admin';\n                $this-\u003e_db-\u003einsert($tableName, $data);\n            }\n            \n            function down()\n            {\n                $tableName = $this-\u003e_tablePrefix . 'users';\n                $sql= \"DROP TABLE IF EXISTS $tableName\";\n                $this-\u003e_db-\u003equery($sql);\n            }\n        \n        }\n        \n4. If you want a table prefix, add this to your `application.ini`:\n\n        resources.db.table_prefix = \"prefix\"\n\n\n        \n        \n## Phing Task\n\n1. Define the phing task in the `build.xml`\n\n        \u003ctaskdef name=\"dbmigration\" classname=\"phing.tasks.PhingAkrabatDbSchemaManager\" /\u003e\n        \n2. Setup a phing target with the database options in the `build.xml`\n \n        \u003ctarget name=\"database-migration\"\u003e\n        \t\u003cdbmigration adapter=\"mysqli\" host=\"${db.host}\" dbname=\"${db.name}\" username=\"${db.user}\" password=\"${db.pass}\" /\u003e\n\t\t\u003c/target\u003e\n\n3. Run phing using the command line, by `phing database-migration`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakrabat%2Fakrabatzf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakrabat%2Fakrabatzf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakrabat%2Fakrabatzf/lists"}