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 9253639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:16:10+00:00 2026-06-18T11:16:10+00:00

I want to know how Laravel does class loading via Facades. I came across

  • 0

I want to know how Laravel does class loading via Facades.

I came across this answer that said that the DB alias/facade class loaded the code

here /vendor/laravel/framework/src/Illuminate/Database/Connection.php

I tried following the advice given in the answer and following what the code does from index.php but could not understand how the DB Facade loaded the Connection class.

I also got confused some more, because the answer had said that the Connection class is loaded, but that class has no connection method. Yet the documentation says and I have been able to use the connection method like,

DB::connection('my-connection-name'); here’s the link to the docs for this

I want to know where this is all mapped and how does the loading happen. I am guessing that composer has automated the mapping, but where is it actually happening when my application boots?

  • 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-18T11:16:11+00:00Added an answer on June 18, 2026 at 11:16 am

    When you use the static DB call Laravel use the mechanism provided by the Facade class in Illuminate\Support\Facade. The magic method __callStatic is called and retrieved the “original” class which is provided by the DB facade (here db).

    The line 54 in Facade.php show that it use the $app variable (which is static and provided in Illuminate\Foundation start.php file) to get the object registered as DB in the App container.

    return static::$resolvedInstance[$name] = static::$app[$name];
    

    $app[‘db’] is registered in the database service provider.

    Ah, and you are able to use DB and not Illuminate\Support\Facades\DB because an alias is created in app config file.

    I hope this will help you 🙂

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

Sidebar

Related Questions

Want to know what is the difference between ipv4 and ipv6 and how does
Want to know ways to store OBJECTS of a Class in some persistent storage.
I want to know if there is any kind of report on maven that
I started using Laravel (I added RoR as a tag since I know that
i want know if it's possible create a custom delegate in the AppDelegate class,
I want know the passed time that also is between two date, for example
I want to know what events are fired by Laravel core libraries. I want
I want to rename a table in Laravel 4, but don't know how to
I know this is a duplicate question. but i want know it with an
As mentioned in title. I wanna know that does SQL Server can partially execute

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.