Print Available Route in Laravel

This is an article relates on the development of a web-based application using Laravel framework. It is about how to print the possible and available routes which can be used and executed to access certain pages using certain URL address.

To be able to print any available and possible URL address which is provided in the web-based application using Laravel as its framework, a built-in utility such as ‘artisan’ can be very useful to fullfil that purpose. Below is an attempt to do that :

root@hostname:/var/www/html/laravel-project# php artisan routes
  [Symfony\Component\Console\Exception\CommandNotFoundException]  
  Command "routes" is not defined.                                
  Did you mean one of these?                                      
      route:cache                                                 
      route:clear                                                 
      route:list                                                  

In the above output command, there are actually several possibilities which can be used and it will affect or functioning for different purpose.

For the above purpose which is printing the available and possible route of a web-based application developed using Laravel framework, below is the correct execution command :

Continue reading “Print Available Route in Laravel”

Change Primary Key field attribute of Laravel Model

Usually, in web application development based on Laravel framework, a model created in a file form can be associated with a table exist in a database for further binding. So, a controller represented in another file which is used to define the controller class can directly use that model for further action to operate, to query or to access the table associated with it.

An article which is made to show how to create a model in Laravel framework based on PHP programming language exist with a title named ‘Create Model in Laravel using command’ which can be visited in the following link.

After creating the intended model to be used in a controller file for instance to insert a new record based on the model itself. Usually it will try to search a field named id which is marked as a primary key field. But what if that field itself is not exist so the process of inserting new record to the table based on the model is actually failed ?.

Continue reading “Change Primary Key field attribute of Laravel Model”

Using toSql Function to Print SQL Query in Laravel

Somehow, in the development process of a web application based on Laravel PHP Framework, there is a further need to check and recheck the query which is used in the script. Especially if it is actually build with the help of library provided in Laravel PHP Framework. Using the help of ‘DB’ facade which is part of Laravel PHP Framework, it can be specifically modified to print the query which is being used or aim to be executed.

Below is an example of the usage using DB Facade in a controller file :

Continue reading “Using toSql Function to Print SQL Query in Laravel”

Using dd command to debug in Laravel

This is an article which is describing on how to use dd command in order to easily help programmer or developer in order to do a debugging process. The command is actually can only be done in a script for web application based on Laravel PHP framework. The command ‘dd’ is actually stands for ‘Dump and Die’, and it is basically showing the content of a variables in the browser for a simple debugging process to find out whether errors are available by analyzing the content of the variables printed in the browser.

The command or the short helper function which is specifically used to show variable is quite convenient to be utilized in the script based on Laravel PHP framework. Just type the following command in the script for an example :

Continue reading “Using dd command to debug in Laravel”

Views folder permission denied in Laravel 5.3

This is an article where an error generated as ‘views folder permission denied’ at the time of the web application based on Laravel 5.3 framework is being executed. This error actually appeared when the web application based on Laravel 5.3 framework is executed. The error appeared as shown in the image below :

An error which is displayed in the image above can be found in the error log named ‘laravel.log’ stored in the default folder where the log dedicated for web application based on Laravel 5.3 framework, it is located in storage/logs :

Continue reading “Views folder permission denied in Laravel 5.3”

View index not found in Laravel 5.3

This is an article which is created to discuss an error generated as ‘View index not found in Laravel 5.3’. The error itself is explained in the following prove such as an image as follow :

View index not found in Laravel 5.3

Depends on the image which is shown above, the index file is actually located in the default folder which is intented and is used to store the files for view template. It is actually located in resources/views and furthermore to separate the web application into several specific modules, there will be another additional folder located inside ‘resources/views’ for an example an additional folder named ‘server’. So, the full path of the view file will be located in ‘resources/views/server’.

Continue reading “View index not found in Laravel 5.3”

Base table or view not found in Laravel 5.3

This is an article which is focusing on an error generated as “Base table or view not found” as soon as the development of web application using Laravel 5.3 as the main framework is being executed. The error is found when it is executing the web application and the image showing the error can be shown below :

Base table or view not found in Laravel 5.3

It is also shown in the laravel.log file located in storage/logs below :

Continue reading “Base table or view not found in Laravel 5.3”