📜 ⬆️ ⬇️

Console for CodeIgniter

Good afternoon.

I bring to your fair trial a console for PHP CodeIgniter framework.

Before this, a small explanation - I am not a CI fan, but since I have to work in a team with new recruits, the tool that is most readily available for learning is chosen. The same applies to the OS on which Windows is being developed, although the tool has been tested and feels great in Linux-based systems, at least in Ubuntu. This is a prototype, so the code can be criticized endlessly.
')
A small illustrative video:


CI console commands


[] - required, {} - not necessary, you can use paths to subdirectories in names, for example for layouts / header viewlets - creates a directory and in it views from a template.

Generating files from a template

php ci.php create application {applicationName}
php ci.php create controller [controllerName] {actionName1} {actionName2} ...
php ci.php create model [controllerName] {functionName1} {functionName2} ...
php ci.php create view [viewName1] {viewName2} {viewName3}
php ci.php create helper [helperName]

Deleting files

php ci.php remove controller [controllerName]
php ci.php remove model [controllerName]
php ci.php remove view [viewName]
php ci.php remove helper [helperName]

Installing bundles

php ci.php install tankauth-1.0.9
php ci.php install zend-1.11.10
php ci.php bundle install hmvc

Removing bundles

php ci.php uninstall tankauth-1.0.9
php ci.php uninstall zend-1.11.10
php ci.php bundle uninstall hmvc

List of available bundles

php ci.php list
php ci.php bundle list

Additionally

php ci.php help / php ci.php? (read usage documentation)
php readme hmvc (read readme by bundle)
php bundle readme hmvc (read readme by bundle)

In the near future I want to make the possibility of migrations for the database. Using the folder from the framework / application / migration / and add descriptions for bundles (on the site and list for general viewing ).

Explanations


0. Correct work in Windows XP (cmd.exe), and Linux (bash).

1. Creating an application is actually installing the bundle in the current directory where you are located, in fact, ci create application example == ci install codeigniter-2.0.2

2. I think everything is clear with the creation of controllers, models and helpers, the usual creation of templates with the correct naming and arrangement of the framework files.

3. Delete - normal erase.

4. Actually the main thing is the bundles. The installation is downloading a zip archive and unpacking it to the root. And the subsequent downloading of the installation script and its execution. For example, tankauth-1.0.9 - entering the necessary data in the database:

$sql = <<<SQL SQL; include BASEPATH . DS . 'application' . DS . 'config' . DS . 'database.php'; $dbdriver = $db['default']['dbdriver']; $hostname = $db['default']['hostname']; $database = $db['default']['database']; $username = $db['default']['username']; $password = $db['default']['password']; try { $dbh = new PDO("$dbdriver:host=$hostname;dbname=$database", $username, $password); $dbh->exec($sql); $dbh = null; } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } 


When unpacking, the list of all installed files is saved in /application/logs/tankauth-1.0.9.log, at least you can delete the bundle without the Internet, except for the uninstall script, of course.

5. Removing a bundle is the opposite of installing, all files and empty directories are deleted from /application/logs/tankauth-1.0.9.log, then the removal script is downloaded and run, if there is one.

6. You can add your bundles to config / bundles.json

7. Bunlde now I collect it myself, the list is not thick:

Download link: bitbucket.org/anatooly/ciconsole/downloads/20111014-ciconsole.zip
Project Link: bitbucket.org/anatooly/ciconsole

I will be glad to hear constructive criticism.

Udp .: added a few bundles, display their list and readme for each. Wiki Link: bitbucket.org/anatooly/ciconsole/wiki/Home

Source: https://habr.com/ru/post/126833/


All Articles