Laravel .env.example: APP_XXX Values Explained

Поделиться
HTML-код
  • Опубликовано: 30 сен 2024

Комментарии • 63

  • @Heatedpillow
    @Heatedpillow 2 года назад +21

    Worth noting:
    env() fuction should only be used in config files and not anywhere else 👍

    • @sirajul-anik
      @sirajul-anik 2 года назад +1

      nope, not exactly true. Till you run `php artisan config:cache`. otherwise, it's just okay.

    • @Heatedpillow
      @Heatedpillow 2 года назад +3

      @@sirajul-anik Yes and no :)
      Proper projects with deployments should use env only in configuration files.
      Snippet from laravel docks:
      If you execute the command during your deployment process, you should be sure that you are only calling the function from within your configuration files. Once the configuration has been cached, the file will not be loaded; therefore, the function will only return external, system level environment variables.

  • @OivlisLHog
    @OivlisLHog 7 месяцев назад +1

    you completely forgot to mention the caching part regarding to what APP_ENV is declared, which is not documented and hidden. It seems that anything that is not "local" will cache routes, for example. But i don't find out what/where the logic is. It gets complicated when you not only have "local" and "production" but also multiple stagings and multiple develop environments where caching should not happen but it does. Docs just tell nothing about it

  • @fr402s
    @fr402s Год назад

    problem , your explanation show something locally.. when we are in a server. step are different. im lost from there. ( i use plesk)

  • @jatinchauhan323
    @jatinchauhan323 2 года назад +1

    Lol i suffered a lot with this server error problem for about 2 months

  • @chanakakasun7843
    @chanakakasun7843 2 года назад +1

    Thanks for this video .Most of developers actually don't know the meaning of these.Keep up the good work.I am wathing your daily videos and I learned so many stuff about laravel from your videos .thaks again.

  • @Avefenixfuego8
    @Avefenixfuego8 2 года назад +1

    Nice, I have had one trouble with APP_URL and I changed for full url and then few days there was some parts didn't work. Thanks for sharing your advice.

  • @amitsolanki9363
    @amitsolanki9363 8 месяцев назад

    Sir can i set values from database into env file?

  • @challenger7540
    @challenger7540 2 года назад

    How can i pass some env values from database ? for example MAIL_HOST or password and etc..I wanna get this kind of data from database , to can make it change dynamicly ??

    • @LaravelDaily
      @LaravelDaily  2 года назад

      Yes you can set something like config('xxx.yyy', DB::table('config')->where()->first()->value);

  • @JohnSmithhh
    @JohnSmithhh Месяц назад

    Can you make a video of how you handle .env variables? Let me explain:
    I want to separate local / staging / production, I also want my local AND staging AND production connexion to be automatically just by changing APP_ENV.
    I can't believe there's no solution to just overwrite the same variable when getting from local to prod, why not keeping all important connexion data in the env file and just use prefix? Like this:
    .env file:
    APP_ENV=local
    DB_PREFIX_PRODUCTION=prod_
    DB_PREFIX_STAGING=staging_
    DB_PREFIX_LOCAL=local_
    DB_DATABASE_LOCAL=local_app
    DB_HOST_LOCAL=127.0.0.1
    DB_USERNAME_LOCAL=root
    DB_PASSWORD_LOCAL=''
    DB_DATABASE_PRODUCTION=PROD_app
    DB_HOST_PRODUCTION=prod-rds-endpoint
    DB_USERNAME_PRODUCTION=your_prod_username
    DB_PASSWORD_PRODUCTION=your_prod_password
    So in my database.php it will automatically take the right connexion:
    $env = env('APP_ENV');
    'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST_' . $env),
    'port' => env('DB_PORT_' . $env),
    'database' => env('DB_DATABASE_' . $env),
    'username' => env('DB_USERNAME_' . $env),
    'password' => env('DB_PASSWORD_' . $env),
    'prefix' => env('DB_PREFIX_' . strtoupper(env('APP_ENV')), ''),

    • @LaravelDaily
      @LaravelDaily  Месяц назад +1

      If I understand your problem correctly, that is solved by creating multiple drivers in config/database.php, not in .env file.

    • @JohnSmithhh
      @JohnSmithhh Месяц назад +1

      @@LaravelDaily ok I will check that, btw thank you for all your content it really helps me getting better and understanding how senior dev use laravel 👍 I really appreciate!

  • @grayos14
    @grayos14 Год назад

    Thank you Laravel Daily

  • @g0disn0where
    @g0disn0where 2 года назад

    MacBook upgrade :)

  • @BriceGyebre
    @BriceGyebre 6 месяцев назад

    Great Thanks

  • @jimishukurow2286
    @jimishukurow2286 2 года назад +1

    Royal like from me!

  • @Stoney_Eagle
    @Stoney_Eagle 2 года назад +2

    Maybe a good video is how to make sure your emails get into your users inbox and not in their spam folder.
    It takes a bit of work to verify your domain but this prevents that the user can't find their email.

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      It's way outside of topic of Laravel, and I'm surely not an expert on email delivery.

    • @Stoney_Eagle
      @Stoney_Eagle 2 года назад

      @@LaravelDaily It was a suggestion because every laravel developer needs to setup their email provider in laravel and create email templates.

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      Good suggestion about the PROBLEM, but a wrong person to ask - I'm not qualified enough to talk about it.

    • @Stoney_Eagle
      @Stoney_Eagle 2 года назад

      @@LaravelDaily I've seen the Laravel videos declining lately and people like good tutorials about specific topics.
      Just trying to give you some ideas here and there that will attract new viewers 😉

    • @p30mehrdad
      @p30mehrdad 2 года назад

      ​@@LaravelDaily See , your community is growing!!
      Congratulations.

  • @abdulmujeeb7552
    @abdulmujeeb7552 2 года назад +1

    Thanks for sharing

  • @raheelaslam3909
    @raheelaslam3909 2 года назад +1

    Great, Thanks

  • @adilizm704
    @adilizm704 2 года назад +1

    Hello sir pls explain to us why when i link my laravel project to multiple databases using a unique connection each the command '' php artisan migrate:fresh '' drop only tables from default DB then show error for other databases (error: table already exist ) pls help ,appreciated for more tips on that topic

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      I don't work with projects with multiple databases, so I don't know the answer

    • @p30mehrdad
      @p30mehrdad 2 года назад

      look this one:
      ruclips.net/video/KJAXLf78QPs/видео.html

  • @sirajul-anik
    @sirajul-anik 2 года назад

    As you said, "APP_URL" is for URL generation, Laravel uses APP_URL when it's generating URL from the CLI, which means in schedulers, jobs etc

  • @lil_wish2022
    @lil_wish2022 2 года назад

    hi, i'm your russian fan, i'm studying and i'm having some difficulties with my project laravel + vue. You can shoot a video with authorization and registration via api

  • @GergelyCsermely
    @GergelyCsermely 2 года назад +1

    Thanks

  • @traoreahmed2363
    @traoreahmed2363 2 года назад +1

    thanks

  • @amitsolanki9363
    @amitsolanki9363 8 месяцев назад

    Sir can i set values from database into env file?

    • @LaravelDaily
      @LaravelDaily  8 месяцев назад +1

      No, but you can dynamically set them with config() function

    • @amitsolanki9363
      @amitsolanki9363 8 месяцев назад

      Ok,
      I have a doubt if I will fetch data from DB inside AppServiceProvider boot(), will data fetch only first time from database when server is started or every time when user request on a server.

  • @exceed7969
    @exceed7969 2 года назад

    So in my project, there is an app_key already set.
    Now, there is another feature to be added where you can store passwords, like a Vault. usercodes and passwords should be encrypted but I am required to use another app_key for it. Could this be possible?

    • @LaravelDaily
      @LaravelDaily  2 года назад

      I've never done it like that, so probably it's not possible with standard features, you need to come up with some extra logic for this.

  • @NebsterSK
    @NebsterSK 2 года назад

    Should APP_DEBUG be true or false during automated tests (phpunit)?

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      True. When testing, you DO want to see errors if the tests fail, don't you?

  • @tworc20
    @tworc20 2 года назад

    Sir, could you please make a video how to deploy laravel in windows server 2019 for local network?

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      I don't use Windows server, and not really recommend it to anyone.

  • @marcusgaius
    @marcusgaius 2 года назад

    IIRC, welcome blade used to pull the page title from .env
    Not sure when or why was it changed to hardcode. Not that that file ever gets used, anyway.

    • @LaravelDaily
      @LaravelDaily  2 года назад +2

      I then understood why. The new welcome page is full of Laravel-related links and tools, so it is actually LARAVEL homepage, not YOUR APP homepage. It makes perfect sense.

  • @Viveksharmaa
    @Viveksharmaa 2 года назад +2

    Amazing... I learnt how to search config in code.

  • @fcolecumberri
    @fcolecumberri 2 года назад

    I find some overlapping with APP_ENV and APP_DEBUG is there a case you want to have debug=true on env=production or debug=false on env=local?

    • @LaravelDaily
      @LaravelDaily  2 года назад

      Yes technically you may combine them like this, but in practice I never needed that

    • @fcolecumberri
      @fcolecumberri 2 года назад +1

      @@LaravelDaily I am not saying I need that, I just find odd that laravel have 2 different inputs for the same concept.

    • @LaravelDaily
      @LaravelDaily  2 года назад

      It's not the same concept. Debug is for debugging, and env can be used much broader, for any check

  • @ricko13
    @ricko13 2 года назад

    5:53 but what about if the key gets leaked?

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      Technically, you're in trouble, then, if someone knows how to use this key.
      Nothing from the production .env should ever get leaked.

  • @odehadejoh9966
    @odehadejoh9966 2 года назад

    The app name is used in the title tag of the base template, app.blade.php. I noticed this as my browser always showed Laravel on the tab unless I updated this value.

    • @LaravelDaily
      @LaravelDaily  2 года назад

      You're probably talking about one of the starter kits? Laravel Breeze? Cause in the default Laravel, there's no app.blade.php, only welcome.blade.php github.com/laravel/laravel/tree/8.x/resources/views

    • @odehadejoh9966
      @odehadejoh9966 2 года назад

      @@LaravelDaily Oh, yeah. Laravel UI and Jetstream I've used, and both were that way.
      However, the title tag in welcome.blade.php seems to be updated to reference the app.name config once a starter kit is added as well.

    • @sohailahmad2982
      @sohailahmad2982 2 года назад

      Hello Mr Laravel Daily please make a video for multi auth with different tables (for example Doctor tables , patient tables and Admin tables etc) with one login form.

  • @sohailahmad2982
    @sohailahmad2982 2 года назад

    Hello Mr Laravel Daily please make a video for multi auth with different tables (for example Doctor tables , patient tables and Admin tables etc) with one login form.

    • @LaravelDaily
      @LaravelDaily  2 года назад +2

      I wouldn't personally use such structure, I would put it all in one users table, with maybe some additional fields separately.

    • @sohailahmad2982
      @sohailahmad2982 2 года назад

      @@LaravelDaily ok sir but we want for multiple tables

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      Ok then, if you want for multiple tables, then build it yourselves. I can't shoot a video teaching something that I think is very wrong.

    • @sohailahmad2982
      @sohailahmad2982 2 года назад

      @@LaravelDaily sir i am sorry but why my method is wrong ?

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      Watch my video: ruclips.net/video/kZOgH3-0Bko/видео.html