CodeIgniter Forums
Craftsman - Interactive CLI - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: Craftsman - Interactive CLI (/showthread.php?tid=62713)



Craftsman - Interactive CLI - dsv - 08-18-2015

Hello community!!

Craftsman is a CLI for Codeigniter 3.0 using Symfony Console component. Provides a number of helpful commands for your use while developing your application.

The generation command provides a variety of generators to speed up your development process:
  • Controllers
  • Models
  • Views
  • Migrations
  • Seeds

The seeder command uses a simple method of seeding your database with test data using seed classes.

The migration command shows the possible scenario (up/down) before running the scheme selected, here's a list of useful commands that you can use:
  • check: display the current migration scheme status.
  • latest: migrate to the latest version, the migration class will use the very newest migration found in the migration directory.
  • version: can be used to rollback changes or step forwards programmatically to specific versions.
  • rollback: rollback the last migration operation
  • reset: rollback all migrations
  • refresh: rollback all migrations and run them all again

Demo:

[Image: 95481.png]

Finally here's the documentation of Craftsman:

https://github.com/CI-Craftsman/CLI


RE: Symfony Console CLI for Codeigniter 3.0 - rakibtg - 08-18-2015

Great stuff!


RE: Symfony Console CLI for Codeigniter 3.0 - dsv - 08-18-2015

(08-18-2015, 11:19 AM)rakibtg Wrote: Great stuff!

Thank you rakibtg!!


RE: Craftsman CLI - dsv - 04-07-2016

Craftsman now supports HMVC Environments with a new feature: 'Modular Migrations'.

Modular Migrations: manage your database scheme's evolution through independent versions of your components.

Example:

Suppose we have our application directory:

Code:
+- APPPATH/
| +- migrations/
| | +- 001_add_blog.php
| | +- 002_add_posts.php

And an application library uses a database scheme (like Ion Auth, etc). This migrations reside in:

Code:
+- APPPATH
| +- libraries/
| | +- XLib/
| | | +- migrations
| | | | +- 001_add_session.php
| | | | +- 002_add_other_stuff.php

If you're familiar with the Codeigniter Migration Class, it is imposible to maintain separated migration version files in your application, you need to merge these files in one directory and fix the migration file name.

With Craftsman you can run the command:

Code:
php vendor/bin/craftsman migration:latest --path="application/libraries/XLib"

And that's all, your migrations are now independent.

In your database you can see that every component have a version assigned:

Code:
mysql> SELECT * FROM ci_migrations;

+---------------+---------+
| module        | version |
+---------------+---------+
| ci_system     |       2 |
| xlib          |       2 |
+---------------+---------+

Also you can change the component name stored in the database with the '--name' option:

Code:
php vendor/bin/craftsman migration:latest --name="foo" --path="application/libraries/XLib"



RE: Craftsman CLI - dsv - 07-09-2016

Now with Craftsman you can test your application without installing a web server using the serve command:

Code:
php vendor/bin/craftsman serve

Arguments:
  • --host: The host address to serve the application on (default:localhost).
  • --port: The port to serve the application on (default: 8000).
  • --docroot: Set an explicit document root (default: cwd).



RE: Craftsman CLI - dsv - 12-08-2016

Craftsman v4+ comes with a built in REPL command that makes it easy to explore your application in an interactive console. You can start the interactive console using:

Code:
php craftsman console

This will bootstrap your application and start an interactive console. At this point you can interact with your application code and execute queries using your application’s models:

Code:
php craftsman console

Craftsman v4.2.1 Console
---------------------------------------------------------------
Codeigniter : $CI
Path: ~/codeigniter/application
---------------------------------------------------------------
Psy Shell v0.7.2 (PHP 7.0.12 — cli) by Justin Hileman
>>> $CI->load->model('foo_model');
=> CI_Loader {#153}
>>> $Foo = $CI->foo_model;
=> Foo_model {#313}
>>> $Foo->find_all();

To quit you can use CTRL-C or by typing exit.


RE: Craftsman - Interactive CLI - dsv - 01-09-2017

Checkout the new demo!!

[Image: 96649.png]


RE: Craftsman - Interactive CLI - abmcr - 02-05-2017

I have a problem with the installation; latest CI vanilla

Code:
xxxxxxxx@MacBook-Pro-di-Andrea:/Applications/MAMP/htdocs/CodeIgniter-3.1.3$ composer require craftsman/cli
Using version ^4.2 for craftsman/cli
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - craftsman/cli 4.2.1 requires codeigniter/framework ~3.0 -> satisfiable by codeigniter/framework[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.1.0, 3.1.1, 3.1.2, 3.1.3].
    - craftsman/cli 4.2.5 requires codeigniter/framework ~3.0 -> satisfiable by codeigniter/framework[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.1.0, 3.1.1, 3.1.2, 3.1.3].
    - Can only install one of: codeigniter/framework[3.0.0, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.0.1, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.0.2, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.0.3, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.0.4, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.0.5, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.0.6, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.1.0, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.1.1, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.1.2, No version set (parsed as 1.0.0)].
    - Can only install one of: codeigniter/framework[3.1.3, No version set (parsed as 1.0.0)].
    - Installation request for codeigniter/framework No version set (parsed as 1.0.0) -> satisfiable by codeigniter/framework[No version set (parsed as 1.0.0)].
    - Installation request for craftsman/cli ^4.2 -> satisfiable by craftsman/cli[4.2.1, 4.2.5].


Installation failed, reverting ./composer.json to its original content.



RE: Craftsman - Interactive CLI - dsv - 02-20-2017

(02-05-2017, 10:08 AM)abmcr Wrote: I have a problem with the installation; latest CI vanilla

Code:
xxxxxxxx@MacBook-Pro-di-Andrea:/Applications/MAMP/htdocs/CodeIgniter-3.1.3$ composer require craftsman/cli
Using version ^4.2 for craftsman/cli
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

 Problem 1
   - craftsman/cli 4.2.1 requires codeigniter/framework ~3.0 -> satisfiable by codeigniter/framework[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.1.0, 3.1.1, 3.1.2, 3.1.3].
   - craftsman/cli 4.2.5 requires codeigniter/framework ~3.0 -> satisfiable by codeigniter/framework[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.1.0, 3.1.1, 3.1.2, 3.1.3].
   - Can only install one of: codeigniter/framework[3.0.0, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.0.1, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.0.2, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.0.3, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.0.4, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.0.5, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.0.6, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.1.0, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.1.1, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.1.2, No version set (parsed as 1.0.0)].
   - Can only install one of: codeigniter/framework[3.1.3, No version set (parsed as 1.0.0)].
   - Installation request for codeigniter/framework No version set (parsed as 1.0.0) -> satisfiable by codeigniter/framework[No version set (parsed as 1.0.0)].
   - Installation request for craftsman/cli ^4.2 -> satisfiable by craftsman/cli[4.2.1, 4.2.5].


Installation failed, reverting ./composer.json to its original content.


Could you provide your composer.json file please?


RE: Craftsman - Interactive CLI - cvetan - 04-03-2018

It doesn't work.

I followed docs, and when i try to generate controller for exaple i got error:

Code:
PHP Parse error:  syntax error, unexpected '|', expecting variable (T_VARIABLE) in /var/www/html/newcms/vendor/craftsman/cli/src/Commands/Serve.php on line 94
PHP Stack trace:
PHP   1. {main}() /var/www/html/newcms/vendor/craftsman/cli/craftsman:0
PHP   2. spl_autoload_call() /var/www/html/newcms/vendor/craftsman/cli/craftsman:32
PHP   3. Composer\Autoload\ClassLoader->loadClass() /var/www/html/newcms/vendor/craftsman/cli/craftsman:32
PHP   4. Composer\Autoload\includeFile() /var/www/html/newcms/vendor/composer/ClassLoader.php:322

Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /var/www/html/newcms/vendor/craftsman/cli/src/Commands/Serve.php on line 94

Call Stack:
   0.0001     241328   1. {main}() /var/www/html/newcms/vendor/craftsman/cli/craftsman:0
   0.0127    2461032   2. spl_autoload_call() /var/www/html/newcms/vendor/craftsman/cli/craftsman:32
   0.0127    2461080   3. Composer\Autoload\ClassLoader->loadClass() /var/www/html/newcms/vendor/craftsman/cli/craftsman:32
   0.0127    2461224   4. Composer\Autoload\includeFile() /var/www/html/newcms/vendor/composer/ClassLoader.php:322