Laravel DotEnv not reading server environment variables - laravel

I'm trying to get a Laravel app working in an automated deployment setup.
Everything deploys fine, but I get the following 500 hundred error.
Illuminate\Encryption\MissingAppKeyException: No application encryption key has been specified.
Now, there is no .env file but the variables are all defined already on the server. If I ssh into my server and type env I can see APP_KEY in the list with the right value, but my Laravel app can not see it.
I have tried refreshing caches etc, but still, it doesn't work.
Can Laravel not use server environment variables?

if APP_KEY already in .env, may you run php artisan config:cache.

Related

DigitalOcean App (Laravel) is Not Connecting to Managed MySQL database, times out

I have a rather large Laravel 8 Project I am moving from Digital Ocean Droplet into Apps.
I specified all DB_* environmental App-Level Environment Variables exactly like they are in my prod .env
I have added that Database as resource in my App (with username/database).
I made sure my App is in Trusted Sources on that Database.
Yes, I am using public credentials as Apps do not live in VPC
I push Deploy and build goes fine until it reaches php artisan package:discover and it just times out there for 30+ seconds and deploy crashes.
If I omit database configuration altogether (i.e. empty DB_* App-Level Environmental Variables) - package:discover runs fine, however, there is no connection to db.
Even if I skip package discovery and allow build to finish, I am UNABLE to connect to database from Apps with credentials provided by DigitalOcean.
Unfortunately build never happens so I cannot even see the logs.
The same Laravel code connects to the same database with same credentials on a Droplet without a problem.
Again this is DO managed Database. I cannot really access it and mess with users. Also Apps does not have static IP address to add it to Trusted Sources. Only can be added by name.

Sending emails via gmail, Laravel

can anyone know if there is any difference in sending emails via gmail in Laravel 5.5 on localhost and on global server, because on localhost everything works fine, emails are sent without problem but on global server all the time crashes my authentication error go on configuration connection does not change. Of course, I have enabled mail access for less secure applications. I wonder if it's a problem with mail or a change of environment, from local to global, or something else must change in the .env file configuration or directly in the application. Thank you in advance for your help
Yes. Possibly it occurred because of app environment. Try keeping debugging on. And trace back the authentication error. Try sending dummy email with simple text.
And after making changes in env file empty config caches using php artisan cache:clear. Many times config doesn't change because of caching.
Good Luck!

Setup Laravel 5 Application without command-line access

Is it possible to Setup Laravel 5 Application without command-line access?
It's a common task do these commands with Laravel 5:
composer install
php artisan migrate
php artisan db:seed
gulp
[...]
Consider a non-dedicated server without SSH access, how can I setup the application in that environment?
Yes it is possible.
Briefly, when you have developed your Laravel on local environment you need to use FTP client/software (Like FileZilla FTP client) to upload the content to your host provider.
Before that you need to ensure some technical details so it can work
Ensure have write permission to folder Storage.
All Laravel folder should be upload, but the domain should point to Public folder.
You need to configure your host MySQL database information in your project.
And it should work, the only challenge left here is to ensure you find host providers that allow make modifications on 1 and 2.
I suggest you to try it before distributing it to your customers and make a step-by-step guideline, as there is risk for unseen scenarios.
In addition to my answer, few links for reading:
http://novate.co.uk/deploy-laravel-5-on-shared-hosting-from-heart-internet/
https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e#.vv4wgkdrw
Deploy Laravel 5 using only FTP in a shared hosting

how to run php artisan migrate from within my virtual machine

I've just started with Laravel, installed on WAMP server, and when trying to migrate the first tables, I get and error saying that homeasted#localhost user has no premission, but I dont know how to change it to work on my virtual machine. What should I do?
Please check out Laravels Homestead – it is easy to setup and provides you with a webserver, ready to use and pre-configured for Laravel.
But if you want to use WAMP, you have to:
1) Create a database for your new Laravel installation. Go to your local phpmyadmin, which comes pre-installed with WAMP Server. Login to your database (default username should be 'root', password is blank). There you can manage your databases. Go ahead and create one for your Laravel installation. (There are many tutorials about how to create a database with phpmyadmin)
2) Go to the root directory of your Laravel installation. Open the file called .env.example and fill in your database settings. Then save it to .env. This should get your database connection up and running. Read more about .env in the laravel docs.
If you're using Homestead, you do not need WAMP server. To run migrate command, you need to run vagrant up to start the VM box and then run vagrant ssh command to run SSH. Only after that you should run php artisan migrate command.
Please check here i think that can help you.
https://laracasts.com/discuss/channels/general-discussion/homestead-db-connection-problem
well you can change the table name in .env file which is present in the root directory
If it is not present in there (as it is not available in laravel 5.2) please download it.
Enjoy

Laravel 5 mailgun works locally (Mac OS) but nothing happened on live server

I developing a web application using Laravel 5, application needs send email to members when they registered.
I use mailgun as mail driver, everything works fine locally on my Mac Book Pro machine, it means everything should configured correctly, but when I move to Ubuntu server (14.04), the mailgun didn't send any email out neither any error message.
I tried using curl command on server, it works fine, means server should not block any port for mailgun.
Anyone please can help on this issue?
As this works from one environment, and not in another, it's very likely to be a configuration problem. This might differ in a few places with mail in Laravel.
You'll need to check that pretend in config/mail.php is set to false. See here.
You'll need to make sure your .env file (if you're using .env) is first renamed from .env.example to .env and then check that the settings are set up correctly for Mailgun. I wrote a small tutorial for Mailgun Laravel 5 here if you have any problems with that.
You'll need to check that the third party services file in config/services.php is configured correctly. More specifically, you need to ensure that the API key is set up correctly.
If none of these work correctly, then you'll almost certainly have some error message in your storage/logs folder, I recommend checking here for some hints.
Most of the time this happens due to wrong env configuration try this one. You can simplify the confusion between the Mail.php and .env settings

Resources