Home » Laravel 6 Define Global Constants Config PHP file

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.

Read Also:  How to get last inserted id in laravel 5.8?

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:

Read Also:  VueJS CRUD Operations with PHP and MySQLi Example

config/global.php

<?php
   
return [
    'support_email_address' => '[email protected]_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.

Read Also:  $event Object as Parameter using Angular Example

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  jQuery Ajax Bootstrap Table Pagination using PHP MySQLi
  2. Read Also:  reactjs open link in new tab Example Tutorial
  3. Read Also:  Top 10 Yii Interview Questions and Answers for fresher
  4. Read Also:  Global Config variable In Laravel 6 Example
  5. Read Also:  Create Contact Form And Send Email using PHP
  6. Read Also:  PHP Array Length Size Count Tutorial With Example
  7. Read Also:  Different CSS Textbox styling Examples
  8. Read Also:  Jquery Responsive Fancybox Popup Example
  9. Read Also:  PHP Laravel 6 Global Variable Example
  10. Read Also:  How to Declare Global Variable in Laravel 6?

Leave a Comment

Your email address will not be published. Required fields are marked *