how to create laravel Project and run without artisan

how-to-create-laravel-and -run-without-artisan
Create Laravel Application and Run without artisan command
In this post, I will going to explain about how to Create Laravel project and run laravel project without “php artisan serve” command. At first, create a laravel project. After installing a laravel project you have to use “php artisan serve” command in cmd to access the created project. Every time to access your project you have to run this command. It's boring. That's why today, i will going to share a trice of laravel how to run without “php artisan serve” command as like php project (Ex: localhost/your_folder_name).

Two simple steps to run laravel without artisan Command:

.htaccess File:

In public folder, you will see ".htaccess" file. Just Copy this ".htaccess" file from public directory and paste on root of your project directory.

Rename File:

I hope you completed the first step. Now, find the "server.php" file in root of your project directory. Then, just rename to "index.php".

Your job is done. Now, in your browser, just type localhost/your_folder_name and hit Enter key.

By following two simple steps, your Laravel project will run without Php Artisan Serve Command.

If anyone wants to make the application public, the more easy and fastest way is:



  • Rename the "server.php" file in root directory with "index.php".
  • Move your .htaccess from public folder to root directory.
  • Make your directory accessible to Apache2. 

Set correct file/folder permissions:

If you set any of your files/folders with 777 permissions, It's mean you are allowing Anyone to read, write and execute that file/folder in that directory. You have given Anyone (any hacker or malicious person in the entire world) permission to upload Any file/folder, virus or any other file, and Then execute that file.

If you set your files/folder permission to 777 that means you have opened your server to anyone.

Create Laravel Project:

There are few steps to create laravel project. In below, I am going to describe all steps.

Laravel Download and Install Via Composer: 

Laravel framework uses Composer for installation and dependency management. To get Composer visit composer.org . 

Now you can install Laravel by the following command from your terminal:
composer create-project laravel/laravel project_name 

By using the above command, you will be able to download and install a fresh copy of Laravel in a new project_name folder within your current directory.

Alternatively you can also download a  fresh copy of the Laravel repository from GitHub manually. Then you have to run the composer install command in the root of your manually created project directory. This command is responsible to download and install the framework's dependencies.

Apply Permissions After Installing Laravel Project:

After installing Laravel Project, you need to grant the web server write permissions in the app/storage directories.

Need to Serve Laravel after Install Project:

You have to use a web server such as Apache to serve Laravel applications. You can use the serve Artisan command. that is 

php artisan serve

By default the web server is used port 8000. If that port is already in use, you have to specify what port to use. To add another port just add the --port argument:

php artisan serve --port=8080

Directory Structure of Laravel Application:

After installing the Laravel Application, take a look around the laravel application to know about the the directory structure. 

The app directory contains many folders such as Http, Models, Console, Providers and Exceptions. Here, the Http folder contain Controllers and Middleware folders. 

In Controllers folder, all controller pages of the project are located.

In Models folder, all model pages of the project are located. 

database folder contain migrations folder. In migrations folder you can see two migration files named "create_users_table.php" and "create_password_resets_table".

Open "create_users_table.php" file then you can see two different function named "public function up()" an "public function down()". You can create any table using "public function up()" function and using "public function down()" function you can drop any table.

public folder contains css, javascript, bootstrap and image files.

resources folders contains many folders such as js, lang and views. In views folder, all blade pages are located.

routes folder contain web.php page that is responsible to write all route of your laravel project.

In .env file, you can set up database name, user name and user password. That you have created for your project.

Most of your application's code will reside somewhere in this directory. You may also wish to explore the app/config directory and the configuration options that are available to you.

Creating A Migration in your project:

In database folder, there is a file named "create_users_table.php" under migrations folder. In this file by default there is a table Schema "users". Now you can create users table in your database by running migration command.

php artisan migrate

Once the above command is used then your migration table "users" will be created in your database that you have connected in .env file.

You can also create table in database manually. For that you have to put two field in every table. That is created_at and updated_at.

Set Default value current_timestamp for created_at and default value null for updated_at.

In simple php application, you have to create database table manually. But in laravel you can database table with migration command or manually created database table. 

Insert value in database using Laravel:

If everything going fine, now it's time to insert some value in database table using laravel model and controller. For that, you have to create a form design. Assume your form design is ready. Now you have to insert form value in database table. That's why you need to code under store function in controller page. Assume you have written insert code in controller page under store function and you data successfully inserted into associated database table.

Displaying data from your database table:

After inserting data into database table you need to display in web page. That's why you need to code under index function in your controller page.

Actually you have to pass your data view page through controller page. In your view page you need to show your data. your can use php loop to display data. 

By following the above article i hope anyone can easily create laravel application and also able to run laravel Application without artisan command.


EmoticonEmoticon