Make Laravel Artisan Commands

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

9 point/2 review File has been tested

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

Make Laravel Artisan Commands Posted on 12-10-2016  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. 4.5/10 499

Comment:

To comment you must be logged in members.

Files with category

  • SimpleXML is a PHP extension that allows us to easily manipulate and get XML data

    SimpleXML is a PHP extension that allows us to easily manipulate and get XML data

    View: 192    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    SimpleXML provides an easy way of getting an element's name, attributes and textual content if you know the XML document's structure or layout. SimpleXML turns an XML document into a data structure you can iterate through like a collection of arrays...

  • How to use the PHP download file script? Class Download PHP

    How to use the PHP download file script? Class Download PHP

    View: 113    Download: 1   Comment: 0

    Category: Php&mySql     Fields: Other

    This is my favorite PHP download script. I’ve used a different more simple method until a client wanted to be able to allow their site visitors to download a large file from a password protected directory. The PHP script works on Apache web servers...

  • Installing OCI8 & PHP 7.2 on RHEL or CentOS 6

    Installing OCI8 & PHP 7.2 on RHEL or CentOS 6

    View: 258    Download: 0   Comment: 0

    Category: Php&mySql     Fields: Other

    You’ll need to stop Apache (web server) using the following command. In any Linux commands I show in this article, it presumes you aren’t logged in as the root user, so you will need to use sudo to issue privileged commands.

  • PHP source code: get content of google search

    PHP source code: get content of google search

    View: 212    Download: 2   Comment: 0

    Category: Php&mySql     Fields: Other

    How to get the results of google search and display on your website. This PHP code can do that. Refer to the following code.

  • PHP as a Scripting Language for C#

    PHP as a Scripting Language for C#

    View: 153    Download: 0   Comment: 0

    Category: Php&mySql     Fields: none

    When creating .NET applications (including desktop and web applications), it may be useful to allow extending the application using some scripting language. The users of the application can write simple scripts to configure the application, modify...

  • How to Picking the Brains of Your Customers with Microsoft’s Text Analytics

    How to Picking the Brains of Your Customers with Microsoft’s Text Analytics

    View: 4225    Download: 0   Comment: 0

    Category: Php&mySql     Fields: Other

    With the explosion of machine learning services in recent years, it has become easier than ever for developers to create “smart apps”. In this article, I’ll introduce you to Microsoft’s offering for providing machine-learning capabilities to apps.

  • How to MySqli Tutorial PHP MySqli Extension

    How to MySqli Tutorial PHP MySqli Extension

    View: 518    Download: 0   Comment: 0

    Category: Php&mySql     Fields: Other

    PHP provides three api to connect mysql Database.

  • Make Laravel Artisan Commands

    Make Laravel Artisan Commands

    View: 499    Download: 0   Comment: 0

    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.

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