About composer in Laravel and Artisan

Categories: Laravel

About composer in Laravel and Artisan

 

What is Composer?

Laravel 4 consists of many components that are put together automatically into the framework through Composer. Using Composer, you can easily specify which other PHP libraries are used in your code, and initiate installation and update of those dependencies through the command line. You can find more information about Composer in Part 3.

Remember, Part 3 will be our documentation. If you need to find out something, go there. If you can’t find the information, please wait a little bit, I will update it soon.

Method 1: Composer - To create a new app using Composer. Execute this command on Terminal (or Git Bash/Command Prompt on Windows):

1 cd desktop

2 composer create-project laravel/laravel learning travel --prefer-dist

As you see, we go to Desktop by using the cd command, then we let Composer do the magic work. Please wait a little bit. Composer will create a folder called learning travel. It’s our web application. We will use it to develop our first website.

Method 2: Laravel Installer - To create a new app using the new Laravel Installer, execute this command:

1 cd desktop

2 laravel new learning travel

We also go to Desktop by using cd command, then we create our new app. In my opinion, we should use Laravel Installer method, because it’s much faster.

After creating the app, you may need to use Artisan to “serve” your application. (in case you don’t use WAMP or XAMPP)

 

What is Artisan?

Laravel comes with a command line interface called Artisan. We can use Artison to execute repetitive tasks. For example we can launch development server, create models, and run database migrations. You can run Artisan command through your system command line 

(Terminal on Mac, Git Bash on Windows).

You need to navigate to your application folder to run Artisan. 

*Note: I put the app on my Desktop, so I navigate to the Desktop, your path may be different. If you install Laravel using XAMPP or WAMP (for Windows), follow the instruction in Part 3 to create learningLaravel folder.

1 cd desktop/learningLaravel

Then run the command below:

1 php artisan serve

Output:

1 Laravel development server started on http://localhost:8000 

You can now open your web browser, go to localhost:8000 and see your application there. 

php artisan

You should see a list of all commands available trough Artisan CLI. Executing commands through

Artisan affects only the application that you navigated to.

Top Blogs
What is Laravel and its use Published at:- Some Laravel Features Published at:- Laravel Interview Question Answer for Freshers and Experienced Published at:- How to check Laravel version Published at:- Spring vs Laravel : A detail Comparison between Laravel vs Spring Framework Published at:- Powerful New Web Development Features in Laravel 8 Published at:- Laravel – A Trending PHP Framework lets know about this Published at:- Advantages of Laravel Published at:- Laravel Framework Architecture and CodeIgniter Published at:- The Laravel History and Its works framework develop Published at:- About composer in Laravel and Artisan Published at:- Masters of Laravel Structure for web advancement Published at:- Professionals Of Laravel Framework for Internet Development Published at:- Which is Best Laravel or PHP Published at:- Laravel And Vue JS Strong Mix for Web Improvement Published at:- PHP Structures Laravel or Symfony Published at:- What can be the distinctions between WordPress and Headless Laravel CMS Published at:-
R4R.co.in Team
The content on R4R is created by expert teams.