Laravel 6 Define Global Constants Config PHP file

Today, We want to share with you Laravel 6 Define Global Constants Config PHP file.In this post we will show you How to Define Constant Variable in Laravel 6?, hear for How to define Global or constant Variables in Laravel 6 we will give you demo and example for implement.In this post, we will learn about Laravel define global constants Config php file with an example.

Laravel 6 Define Global Constants Config PHP

There are the Following The simple About Laravel6 Define Global Constants Config PHP file Full Information With Example and source code.

As I will cover this Post with live Working example to develop Simple Laravel 6 Define Constant Variable, so the Create and use constants in laravel 6 Examples is following below.

Laravel 6 Create A Config File

first of all I need to make a simple file Like name as a global.php config file with define constants variable data value as well as We can also simple define array value like as bellow Examples:

config/global.php

 'info@your_domain.com',
    'role_type' => ['Manager', 'Admin', 'User'],
]
  
?>

Laravel 6 Use Constant Variable

routes/web.php

We can simplay fetch the value using config() data helper. We can simple bellow laravel 6 example:

Route::get('get-all-role-type', function()
{
    dd(config('global.role_type'));
});

Route::get('get-support-email', function()
{
    dd(config('global.support_email_address'));
});
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about PHP Laravel6 Define Global Constants Config PHP file.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment