Loading...

Make Laravel Artisan Commands

View: 615    Dowload: 0   Comment: 0   Post by: hanhga   Category: Php&mySql   Fields: Other

Artisan is the command line tool used in Laravel framework. It offers a bunch of useful command that can help you develop application quickly.  Apart from Artisan available commands, you can create your own custom commands to improve your workflow. Artisan is driven by the powerful Symfony Console component.

If you have not installed laravel check my previous post on

Laravel Artisan Available Commands

Let’s first check the artisan available commands. To check the available artisan command just type.

php artisan

OR

php artisan list
Laravel Framework version 4.1.9
Usage:
[options] command [arguments]
Options:
--help           -h Display this help message.
--quiet          -q Do not output any message.
--verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version        -V Display this application version.
--ansi              Force ANSI output.
--no-ansi           Disable ANSI output.
--no-interaction -n Do not ask any interactive question.
--env               The environment the command should run under.
Available commands:
<strong>changes</strong>                     Display the framework change list
<strong>clear-compiled</strong>              Remove the compiled class file
<strong>down</strong>                        Put the application into maintenance mode
<strong>dump-autoload</strong>               Regenerate framework autoload files
<strong>env</strong>                         Display the current framework environment
<strong>help</strong>                        Displays help for a command
<strong>list</strong>                        Lists commands
<strong>migrate</strong>                     Run the database migrations
<strong>optimize</strong>                    Optimize the framework for better performance
<strong>routes</strong>                      List all registered routes
<strong>serve</strong>        Serve the application on the PHP development server
<strong>tail</strong>                        Tail a log file on a remote server
<strong>tinker</strong>              Interact with your application
<strong>up</strong>                Bring the application out of maintenance mode
<strong>workbench</strong>          Create a new package workbench
<strong>asset</strong>
asset:publish               Publish a package's assets to the public directory
<strong>auth</strong>
auth:clear-reminders        Flush expired reminders.
auth:reminders              Create a migration for the password reminders table
auth:reminders-controller   Create a stub password reminder controller
<strong>cache</strong>
cache:clear                 Flush the application cache
<strong>command</strong>
command:make                Create a new Artisan command
<strong>config</strong>
config:publish              Publish a package's configuration to the application
<strong>controller</strong>
controller:make             Create a new resourceful controller
<strong>db</strong>
db:seed                     Seed the database with records
<strong>key</strong>
key:generate                Set the application key
<strong>migrate</strong>
migrate:install             Create the migration repository
migrate:make                Create a new migration file
migrate:refresh             Reset and re-run all migrations
migrate:reset               Rollback all database migrations
migrate:rollback            Rollback the last database migration
<strong>queue</strong>
queue:failed                List all of the failed queue jobs
queue:failed-table          Create a migration for the failed queue jobs database table
queue:flush                 Flush all of the failed queue jobs
queue:forget                Delete a failed queue job
queue:listen                Listen to a given queue
queue:retry                 Retry a failed queue job
queue:subscribe             Subscribe a URL to an Iron.io push queue
queue:work                  Process the next job on a queue
<strong>session</strong>
session:table               Create a migration for the session database table
<strong>view</strong>
view:publish                Publish a package's views to the application

Apart from using the available commands you can create your own commands.

How to Create New Artisan Custom Command

To create a new php artisan command. Type following

 php artisan command:make firstcommand

firstcommand is the name of command.

To define this command go to

/app/commands/firstcommand.php

Open this file and define command functionality in fire method. So whenever this command is executed fire method is called.

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class firstcommand extends Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'command:name';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
//
}
/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return array(
array('example', InputArgument::REQUIRED, 'An example argument.'),
);
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
);
}
}

To make sure artisan know the newly created command Add the following line to yourapp/start/artisan.php file.

Conclusion

This is just an overview of available Artisan commands and how to create custom commands. In my next posts, i’ll explain how to create applications in Laravel framework and how artisan command help you to develop application quickly.

Make Laravel Artisan Commands

Artisan is the command line tool used in Laravel framework. It offers a bunch of useful command that can help you develop application quickly. Apart from Artisan available commands, you can create your own custom commands to improve your workflow.

Posted on 12-10-2016 

Comment:

To comment you must be logged in members.

Files with category

  • Twitter-like Hashtag Function in PHP

    Twitter-like Hashtag Function in PHP

    View: 0    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    If you ever want a function to hashtag and style words within a string which has '#' next to it like twitter. This piece of code will help

  • PSITS Automated Voting System

    PSITS Automated Voting System

    View: 24    Download: 3   Comment: 0

    Category: Php&mySql     Fields: none

    A free sourcecode for PSITS Automated Voting System develop in PHP programming language. The purposed of the system is to automate the process of voting and maintain the quality of data

  • PHP-University Application System

    PHP-University Application System

    View: 30    Download: 6   Comment: 0

    Category: Php&mySql     Fields: none

    Greeting from Malawi the warm heart of Africa. I developed this university registration system project just to share with the people who can make use of the project like this and at the same time for others like students who can learn from it. This...

  • School Event Management System in PHP/MSQLi

    School Event Management System in PHP/MSQLi

    View: 22    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    This School Event Management System can create school events such as Volleyball games, Basketball, Cultural presentation, Election of school officers etc . During school election Instead of having a compile list of candidates and voters this system...

  • Resort Reservation System with PayPal/Credit Card/Debit Card Payment

    Resort Reservation System with PayPal/Credit Card/Debit Card Payment

    View: 27    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    This reservation system has the ability to help its customers find available rooms, cottages and even function hall for their convenience . And in here, they will also have the idea of the room rates where they can quickly reserve for their family...

  • Activity log

    Activity log

    View: 20    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    Simple program to track user's activity log-in time and online/offline status.

  • Electricks - eCommerce

    Electricks - eCommerce

    View: 22    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    Electricks is an e-commerce website built using PHP, Bootstrap and some jQuery plugins. It has all the major functionalities of a typical e-shop. This project was used to present in Southern Luzon State University - Lucban. Feel free to use this code...

  • Simple Email App Using PHP

    Simple Email App Using PHP

    View: 18    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    Creating a simple PHP script using mail function for sending out emails.

 
File suggestion for you
Loading...
File top downloads
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd