Welcome Guest, Not a member yet? Register   Sign In
Craftsman - Interactive CLI
#1

(This post was last modified: 12-09-2016, 09:32 AM by dsv. Edit Reason: Update links )

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
Reply
#2

Great stuff!
Reply
#3

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

Thank you rakibtg!!
Reply
#4

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"
Reply
#5

(This post was last modified: 12-08-2016, 04:49 PM by dsv. Edit Reason: remove hhvm support )

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).
Reply
#6

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.
Reply
#7

Checkout the new demo!!

[Image: 96649.png]
Reply
#8

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.
Reply
#9

(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?
Reply
#10

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
"Well, if crime fighters fight crime and fire fighters fight fire, what do freedom fighters fight?"
Reply




Theme © iAndrew 2016 - Forum software by © MyBB