Giter VIP home page Giter VIP logo

blacksmith's Introduction

Blacksmith

CircleCI

To see the full documentation of the library please go to: Blacksmith Documentation Page

PHP Command Line Interface helper library

This library is intended to help developer to create easily CLI commands using php. It is based on the laravel artisan command but totally independent from it.

This is how the terminal looks when you run:

php blacksmith help

Alt text

Creating a Command

To create a new command, just run:

php blacksmith make:cmd hooray

This will create a file in your-project/commands/Hooray.php. If the /commands directory does not yet exist at the time of creating your first command, Blacksmith will automatically generate it for you.

Organizing Commands

We recommend organizing your commands into subdirectories to keep better track of which command does what. Fortunately, this is easy to do with Blacksmith. To generate a command into a subdirectory just provide the desired path you would like the command to reside in:

php blacksmith make:cmd path/to/hooray

This will generate a file in the following location:

your-project/commands/path/to/Hooray.php

Even if the subdirectories you specified don't exist, they will be created automatically by Blacksmith. The ending path node hooray is considered the command and is where you'll be able to add your command logic.

blacksmith's People

Contributors

eaperezc avatar grahamsutton avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

blacksmith's Issues

Getting "no such file or directory" error for BootstrapCommand

Hey Enrique,

For the bootstrap command, when I run

php blacksmith bootstrap

I am getting the following error when running it locally in our dev environment:

PHP Warning:  copy(/Users/graham1/Documents/Projects/PHP/blacksmith/vendor/bin/blacksmith): failed to open stream: No such file or directory in /Users/graham1/Documents/Projects/PHP/blacksmith/src/Commands/BootstrapCommand.php on line 46

I think we need to figure out a solid way to differentiate between paths for when we're testing it locally and when we're using it directly in the project.

Or should I wait for you to configure it to packagist so we can always test blacksmith directly in an "external" app via install through composer?

Save commands created with "make:cmd" to be added in the commands config file.

Dependency on Issue #7


After the creation of the configurations file, we will need to update the make:cmd call to add newly created commands to the config file we have setup.


Acceptance Criteria

  • The class name of the new command should be added to the commands configuration file at the very end of the process of creating the command.

Allow commands to be registered to a project config file. (YML or JSON, etc...)

For better processing of newly created commands, we need to allow commands to be registered from a project configurations file rather than having to add the classes manually in PHP.

We can use any file type, as long as it is simple to read and write from. Personally, I think we should go with a .yml config file.

Currently, we are doing this to register new commands:

...

// Autoload classes
require_once $autoload_path;

// Get a console instance
$console = new Blacksmith\Console($argv);

// Tell the console which are the commands
// we want available to use
$console->commands = [
    Blacksmith\Commands\HelpCommand::class,
    Blacksmith\Commands\BootstrapCommand::class,
    Blacksmith\Commands\Make\CmdCommand::class,
    Blacksmith\Examples\SayHello::class,
    Blacksmith\Examples\SayBye::class
];

$console->handle();

When we should really have these in a separate file, like this:

commands:
    Blacksmith\Commands\HelpCommand::class,
    Blacksmith\Commands\BootstrapCommand::class,
    Blacksmith\Commands\Make\CmdCommand::class,
    Blacksmith\Examples\SayHello::class,
    Blacksmith\Examples\SayBye::class

The naming for the yml file is obviously not ideal, so we'll need to figure a better namespacing pattern in the near future.

Unit tests for the CmdCommand class.

Unit tests are needed for the CmdCommand class which powers the make:cmd action. This will require the use of vfsStream to also test the command properly creates the right subdirectories for commands that specify them as well as the new command file being created.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.