Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8498663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:27:52+00:00 2026-06-11T00:27:52+00:00

I have just started playing with laravel haveing come from codeigniter and I am

  • 0

I have just started playing with laravel haveing come from codeigniter and I am trying to work out the best way to define a series of constants.
CI uses a constants folder under app/config and I was largely happy with this approach for most things but wanted advice as to the best way to do this in Laravel.

My constants fall into 3 categories and I would like advice if possible on how best to store and retrieve each (baring in mind I’m completely new to Laravel.

Type 1:
Constants which need to be loaded everytime a controller is called:
e.g. I would like to start by defining a constant to tell me if the user is requesting content via ajax, this is what I used to do in CI constants file:
define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')

Type 2:
Constants which can be changed by the user:
Are these best stored in a database or would writing to a config file be a better option? Again looking for advice on how to store and retrieve

Type 3:
Constants which are only needed in specific controllers:
Ideally I would like to be able to group constants into arrays or separate files and pull them out in groups as required.
e.g. I could just retrieve my upload settings for my upload controller.

Thanks for any help/advice in advance – examples would be greatly appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:27:53+00:00Added an answer on June 11, 2026 at 12:27 am

    Type 1
    You can add any constant in Bundle (or application) start.php file.

    Type 2 and 3
    I would suggest using Config for both these requirement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just started playing with core.logic, and to work on it I'm trying to
i have just started playing aorund with asp.net mvc and i want to view
I have just started learning python version 3 and trying to create a file
I have just started playing with Microsoft's 08/2010 WPF Ribbon release. The basics appear
Possible Duplicate: Is JavaScript's Math broken? I have just started playing around with Javascript
I just started playing with memcache(d) last night so I have a LOT to
I have just started programming in C++ and I was playing around with templates.
I have just started playing with TeamCity and its great. Now I got it
I'm new to cmake and have just started playing around with it. My problem
I´ve just started playing around with Java and Hibernate and have gotten an application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.