laravel Archives | Codeexecute

Create custom helper in laravel 5

Laravel support inbuilt helper functionality that we can use in our web application. Please follow the following easy steps to create your own custom helper.

  • First create a folder Helpers in your app directory
  • Now create a file CustomHelper.php in this helpers folder
  • Open newly created file and write the following code
namespace App\Helpers;

class CustomHelper
    public static function myCustomFunction()
        echo "hello world";
  • Open config/app.php and set aliases for you cutsom helper
'aliases' => [
'CustomHelper' => App\Helpers\CustomHelper::class

  • Now ou can use your custom helper’s function in your controller like this

Remove public from url in laravel

By using following steps we can remove public from url

  • Rename server.php to index.php at laravel root folder
  • Copy .htaccess file from public folder to root folder and update code mentioned below

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]



Install Laravel Latest Version with Composer

Laravel is open source and most popular PHP frameworks for rapid web applications development. laravel provides great features like authentication techniques , Artisan , Routing , Eloquent ORM, Query Builder , Blade Templating , Security and many other features thats why its the most popular PHP framework among developers.

In this tutorial we will learn How to install Laravel latest version with composer. so keep follow the below steps .


We need composer to install laravel. If you have already installed composer then skip this step and if you want to install composer then click here and follow steps.

After the composer installation, run the following command to install laravel installer.

composer global require laravel/installer

after this command to scaffold a new application run the following command

laravel new myproject

Alternatively you can also create a new project using create-project command. to create a new application through create-project , run the following command :-

composer create-project --prefer-dist laravel/laravel myproject

Our new laravel project is created and to start the server, run the following command

php artisan serve

this command will start server at You can navigate to or if you installed laravel into xampp then you can also navigate to http://localhost/YourProjectName/myproject/public :).