I have a problem with Laravel spark... I've develop an application and after release at server I have problem with sessions.
Sessions are going expired randomly... Once over 6 hours and once over 2-3minutes... It is very weird...
I am using:
Ubuntu 16.04 at DigitalOcean
Nginx
SSL
Laravel 5.4
Laravel Spark 4.0 with Braintree
My driver settings (from .env) are
BROADCAST_DRIVER=log
CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_DRIVER=database
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
Session configs:
'lifetime' => 36500
'expire_on_close' => false
'encrypt' => false
'lottery' => [2, 10000]
Thanks for help :)
Related
My laravel sanctum - vuejs authentication system works fine ibn localhost. But It does not work in live server. I have tried with various env configurations - but nothing is happening ... My domain has SSL btw
My ENV :
APP_NAME=Laravel
APP_ENV=Production
APP_DEBUG=true
APP_URL=https: // domain.com /
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=*****
DB_USERNAME=*****
DB_PASSWORD=*****
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=cookie
SESSION_LIFETIME=120
SESSION_DOMAIN=domain.com
SESSION_SECURE_COOKIE=false
SANCTUM_STATEFUL_DOMAINS=domain.com
I am sharing the request header :
I found the solution. So I am answering it here so that people with similar problems get benefited. I was using Auth middleware for API protection but implemented manual authentication in the controller instead of default Auth. That causes the problem since the frontend could not match the cookie "Auth" produces.
I have been checking out a lot of answers here and on GitHub regarding this issue, but whatever I try there is always something wrong. I also donĀ“t get why with the same credentials sometimes I am able to connect other times I am not even able to do that.
So right now I get the following error:
"SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed:
nodename nor servname provided, or not known
and I am not able to connect:
My .env credentials:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
My database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST'),
'port' => env('DB_PORT'),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'unix_socket' => env('DB_SOCKET'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
...and for the standard connection, I use 192.168.10.10 for the host.
I think your issue is with the DB_HOST parameter. I included a full explanation. Your fix is likely part of the final paragraph!
Laravel ships with a .env.example configured to connect to the Homestead MySQL out of the box. Assuming you are running everything in Homestead, and Homestead is configured properly, you should be able to use the following database configuration to connect successfully.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
If you are trying to connect to the Homestead database from outside of Homestead, the Laravel documentation describes how you can do that as well. You can check that out here.
Essentially what you need to do is connect to 127.0.0.1 as a host but use a different port (as opposed to 3306.) For MySQL, Homestead exposes a port 33060 that you should try to connect to instead. For Sequel Pro this should fix your issue!
Updated October 2020
If you are using MySql 8 there are some issues with that.
I was also not able to connect with the Laravel Homestead DB.
I solved the problem installing Sequel Ace, the successor of SequelPro which is available also on Mac AppStore.
https://github.com/Sequel-Ace/Sequel-Ace
Here a post from the SequelPro issues about:
https://github.com/sequelpro/sequelpro/issues/3705
I am trying to connect, Local Laravel application to GCP mysql instance. I am just trying to use mysql instance for local development and do not want to upload this on App Engine.
Steps follow:
1. Added IP to Authorized networks in mysql instance
2. updated .env file (refer below)
3. Able to connect to db instance with gcloud sql connect -u=root and access database.
4. Tried configuring config/database.php file
5. Used instance IP for connection instead of localhost
6. used DB_SOCKET : /cloudsql/:asia-northeast1:
.env file
APP_NAME=Laravel
APP_ENV=local
APP_KEY=<app-key>
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=<instance-ip>
DB_PORT=3306
DB_DATABASE=<db-name>
DB_USERNAME=root
DB_PASSWORD=*********
DB_SOCKET=/cloudsql/<project-id>:asia-northeast1:<db-name>
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
config/database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', <instance-ip>),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', <db-name>),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', *********),
'unix_socket' => env('DB_SOCKET', '/cloudsql/<project-id>:asia-northeast1:<db-name>'),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
I have another cakephp 2.0 project which runs locally with no problem.
Thanks in advance
Without knowing what error you actually get it's a bit difficult to know why it doesn't connect. If you can post the actual error you're getting that may tell us why the connection fails.
That being said, you may want to connect using the Cloud SQL proxy instead. There's a quickstart available that takes less than 5 minutes to set up the connection for local testing.
While connecting from Compute Engine your don't need DB_SOCKET. I successfully connected using below DB creds inside laravel's .env.
DB_CONNECTION=mysql
DB_HOST=<Mysql instance IP from Google SQL mentioned under "Connect to this instance">
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=db_user
DB_PASSWORD="db_user_pass"
I have just finished my Laravel development (with some jquery / javascript) project and I am preparing to officially launch the website with vps servier. For the smooth running and security of the website, I only know how to handle some things in the .env file like blow:
Besides this configuration, are there any other things I have handle it before launching the website officially?
.env
APP_NAME=MyProject
APP_ENV=production
APP_KEY=base64:u93RlbQ5zcs.............
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_URL=http://mydomain
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydbname
DB_USERNAME=myuser
DB_PASSWORD=*******************
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=info#mydomain.com
MAIL_PASSWORD=*******************
MAIL_ENCRYPTION=SSL
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
It seems OK, i have seen similar .env files running on various production servers.
I'm migrating a Laravel 5.0 app to 5.4 and am trying to test the mail in my local environment. I've always used Anitix SMTP Imposter for this. Here's what my mail configuration looks like in my .env:
MAIL_DRIVER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPT=null
This has always worked in all previous versions of Laravel (4, 4.2, 5.0), but suddenly with 5.4 I'm getting the following error:
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 220 but got code "500", with message "500 Command not recognized
"
I've tried disabling Avast, using alternative programs like Papercut, playing with the config by using SSL or TLS, but I can't figure out what's causing this. Any ideas?
Late answer, but I came here myself running into the same issue.
MailHog does not support TLS encryption. Adding MAIL_ENCRYPTION=null to my .env file fixed my issue.
First try: php artisan config:cache and restart your local server, perhaps Laravel use the old mail data.
For development purpose https://mailtrap.io/ provides you with all the settings that needs to be added in .env file. Eg:
Host: mailtrap.io
Port: 25 or 465 or 2525
Username: cb1d1475bc6cce
Password: 7a330479c15f99
Auth: PLAIN, LOGIN and CRAM-MD5
TLS: Optional
Otherwise for implementation purpose you can get the smtp credentials to be added in .env file from the mail (like gmail n all)
After addition make sure to restart the server
You can use https://mailtrap.io/
it will provide you all necessary details for you to check mail functions in your local machine including username,password,port,host,etc.
if still have same issue issue,
use these details in config/mail.php file in your project instead of using .env file.
return array(
"driver" => "smtp",
"host" => "mailtrap.io",
"port" => 2525,
"username" => "mailtrap.io_your_username",
"password" => "mailtrap.io_your_password",
"sendmail" => "/usr/sbin/sendmail -bs",
"pretend" => false
);
it is work for me.
MAIL_DRIVER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
I am use a mailhog docker container.
mailhog:
image: mailhog/mailhog:v1.0.0
ports:
- "1025:1025" // smtp
- "8025:8025" // web