- Introduction to PHP
- Introduction to HTML
- HTML5 New Tags
- Style Sheet (CSS)
- Bootstrap (Responsive Design)
- PHP Language Building Blocks
- Conditional Statements
- Introducing ARRAY
- Manipulation User Input
- Reusing Code and Functions
- Object-Oriented PHP
- File System and the Server
- File Uploading & Downloading
- String Manipulation and Regular Expression
- State Management
- MySQL Database
- jQuery with Ajax
- Advance PHP Techniques
- Laravel – Configuration
Php Artisan in Laravel
PHP artisan in Laravel helps in creating projects. It is (command-line) user interface helps in creating application. Php artisan commands help in creating- controller, to create model, help to clear and create cache,see list of routes, making project as maintenance, create testing data, creating Laravel packages etc.
If you start with commands then comes to-:
PHP artisan serve
– This command is used to run the application by using – php development server. As the use of such command is basically for the testing as well as development purpose. Moreover,
– Php artisan serve –host=homestead.app- this is used to change the hostname
– Php artisan serve –port=8080 (You can change the port number by using this command)
– Php artisan serve –host=Laravel.app –port=8080 = (whereas this command is used to change the hostname as well as portno.)
– Now come to create controller- As there are some artisan commands which are used to create controller as-:
Middleware is also a type of controller but it runs before controller. It can also be create through artisan command.
– Php artisan make: middleware TestMiddleware-
This command is used to generate Test/Middleware with the following location-:
– Php artisan make:middleware Admin/ TestMiddleware- It is used to create TestMiddleware inside Admin folder on the following path-:
Now come to create the model
Using artisan command you can also create a model-:
– Php artisan make:model user –
where user is a name of model and it is used to generate the model at following location-:
– Php artisan make.model Models/user
This command is used to develop a model, and the file will be automatically saved at following location-:
Clear the cache-
It is very important feature in Laravel to create the cache by which the speed of the website become fast. There are some artisan commands used as-:
– Php artisan cache:clear- It is used to flush the cache of application.
– Php artisan config:clear- It removes the configuration file from the cache.
– Php artisan route:clear- It is used to clear the route cache file from cache.
– Php artisan view:clear- It will clear all the compiled view files.
– Php artisan optimize:clear- It is used to remove the cached bootstrap file.
Create the cache-
It also has its own commands in Laravel.
– Php artisan config:cache- It is used to create the cache for the fast configuration loading.
– Php artisan route: cache- It is used to create a route cache file for fast registration of route.
– Php artisan view:cache- It is used to clear the compiled view files.
– Php artisan optimizes clear- it removes or clears the cached bootstrap file.
So these are another 4 commands for both creation as well as cache.
Php artisan migrate
By this command you create database table structure. And once table is created, you can login or excess further. So, Laravel has many more features and it is very secure platform. You can create functions fast with artisan commands and you don’t need to create things manually.
Now move forward to maintenance mode. You can put your project on maintenance mode by using artisan commands. For example if you write- “php artisan down” then your project comes in maintenance mode or if you put “php artisan up” you can remove the project from maintenance mode or can say it is used to re-run your project.
If you want to run multiple functions at a time then to manage tasks there is a command known as “php artisan schedule.run”.
Actually, there is a schedule tasks to run the projects in which there is automate sending of emails, automate site maintenance, Automate sms sending etc. so for all these tasks cron jobs are created where only single cron entry is needed on the server.
“php artisan schedule.run”.
But when above schedule run command is executed, Evaluation of schedule tasks are done by Laravel and run the due tasks.
“php artisan schedule.finish”
You can further finish the task by run above command.
Like you have created data in your database and you want to create users in user table and this is done by seed process. Laravel provides seeding the database with testing data with the use of seed classes; all seed classes are stored in database.
Respective command for all this is-:
“Php artisan make:seederUsersData”
When you run the above command then class file is created with the name of “Userdata”. In userdata file you will find run method and following code will put in run method as-:
DB::table (‘users’) ->insert([
And then you will find in database in seed folder- the databaseseeder named file and where again you find the run method, where you will write-:
And run the command- “php artisan db seed” after which the records will be shown in the database. So, this all is called as “dummy data”. Means through ‘php seed command’ you can insert dummy data in your database.
KEY GENERATE BY Artisan command.
As you have notice an application file with extension ‘.env’, in which key is written there. To update or generate new key the command is used as-:
“Php artisan key:generate”. App key is used for security purpose.
Alongwith with these commands there are many more artisan commands but these artisan commands are more in use.
Php artisan make:controllerTestController=
This command will generate a TestController at the following location-:
Php artisan make:controller Admin/TestController-
It is used to create Admin folder then create the TestController inside Admin folder at the following location-:
As above commands are very useful while creating Laravel projects because because cache is needed to be clear after sometime, you can use these commands one by one or you can use these all at once.
As Laravel is very good platform that helps to create login system, user registration etc. by using Laravel command i.e. Php artisan make:auth- command
As by running above command a route is created as-:
Routes-: Auth::routes ();
Controller is also created as-:
Moreover in View the folder is created named as “auth” and further folder paths are created and different files will be created in auth as-: