I have a problem with the configuration in Laravel 5.0
I configured an environment local from an .env file. The machine is a homestead machine and i removed the APP_ENV from the Homestead.yaml just to be sure.
Environment is set to local and i confirmed by prompting $app->environment()
I added a few configuration files to the local config directory (local/filesystems.php, local/mail.php, local/services.php). The interesting thing is the filesystems.php gets loaded but the mail one not. If i dump the getConfigurationFiles() from Illuminate\Foundation\Bootstrap\LoadConfiguration i get
array:11 [▼
"app" => "/home/vagrant/Code/molkerei/config/app.php"
"auth" => "/home/vagrant/Code/molkerei/config/auth.php"
"cache" => "/home/vagrant/Code/molkerei/config/cache.php"
"compile" => "/home/vagrant/Code/molkerei/config/compile.php"
"database" => "/home/vagrant/Code/molkerei/config/database.php"
"filesystems" => "/home/vagrant/Code/molkerei/config/local/filesystems.php"
"mail" => "/home/vagrant/Code/molkerei/config/mail.php"
"services" => "/home/vagrant/Code/molkerei/config/services.php"
"queue" => "/home/vagrant/Code/molkerei/config/queue.php"
"session" => "/home/vagrant/Code/molkerei/config/session.php"
"view" => "/home/vagrant/Code/molkerei/config/view.php"
]
I already tried to clean the cache with php artisan cache:clear but there is not even a cache file (it is set to filesystem)
Any idea why the configuration is not loaded properly?
At the time of writing this answer - there are no more 'sub directories' for config like there used to be in L4 - You now have one main configuration folder.
You overwrite any default config with specific config from your '.env' file if required.
So in your app\config\mail.php file you would write:
'driver' => env('MAIL_DRIVER', 'mandrill'),
Which means it will use Mandrill by default - unless in your .env file you put
MAIL_DRIVER=smtp
which means on your homestead server it will now use SMTP to send the mail.
p.s. I do not know why filesystems loads the local config in your example - it is probably a bug.
Related
Searching using the TNTSearch driver works in a Homestead environment however on production it returns error: the below error,
Symfony\Component\Debug\Exception\FatalThrowableError: Class
'AlgoliaSearch\Version' not found on
vendor/laravel/scout/src/EngineManager.php:31
However my .env has SCOUT_DRIVER=tntsearch and the config file scout.php has:
'driver' => env('SCOUT_DRIVER', 'tntsearch'),
'tntsearch' => [
'storage' => storage_path(),
'fuzziness' => env('TNTSEARCH_FUZZINESS', false),
'fuzzy' => [
'prefix_length' => 2,
'max_expansions' => 50,
'distance' => 2
],
'asYouType' => false,
'searchBoolean' => env('TNTSEARCH_BOOLEAN', false),
]
The problem is that I am not using Algolia search and my composer file has Scout and TNTSearch driver. The search works in my local Homestead environment just not on the production server.
Confirm that SCOUT_DRIVER=tntsearch has been added to your .env file.
For me personally, I had added SCOUT_DRIVER=tntsearch to my local .env file, but not my .env file for the environment with the issue. Don't forget to run php artisan config:clear after adding the env var.
Thanks to #m33bo for pointing me in the right direction!
I worked it out, I had uploaded my project but for some reason the .index file that is needed sync'd but did not work. If this happens to you on live make sure you Git or SVN or whatever the index or run php artisan scout:import App\\Your\\Model
Having created a new user via Voyager, the avatar was showing as a broken image. I uploaded a new image, but the image remained broken.
I checked with Console in Google Chrome and found 3 404 errors:
2017-06-19 10:53:50.159
http://localhost:8888/storage/users/June2017/ypKlbqbATDbpnYctZBFp.png
Failed to load resource: the server responded with a status of 404
(Not Found)
2017-06-19 10:53:50.256
http://localhost:8888/storage/users/June2017/ypKlbqbATDbpnYctZBFp.png
Failed to load resource: the server responded with a status of 404
(Not Found)
2017-06-19 10:53:50.473
http://localhost:8888/vendor/tcg/voyager/assets/images/bg.jpg Failed
to load resource: the server responded with a status of 404 (Not
Found) When I looked at the project, the paths for the 2 storage
errors are: http://localhost:8888/storage/app/public/users/ and:
http://localhost:8888/storage/app/public/users/June2017
While in Media, I'm seeing similar path problems when navigating the folders:
2017-06-19 11:38:22.248 %7B%7B%20selected_file.path%20%7D%7D:1 GET
http://localhost:8888/development/PhpstormProjects/Search4Venues/public/admin/%7B%7B%20selected_file.path%20%7D%7D
404 (Not Found)
Anticipating the question, in .env, I have: APP_URL=http://localhost:8888
Is this a configuration error?
EDIT
A colleague with more experience than me has been through Voyager and found some inconsistencies, which he's attempted to fix.
In app.php, we've had to change:
'url' => env('APP_URL', 'http://localhost:8888/development/PhpstormProjects/Search4Venues'),
... to:
'url' => env('APP_URL', 'http://localhost:8888'),
In filesystems.php, we've had to change:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
]
... to:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/development/PhpstormProjects/Search4Venues/public/storage',
'visibility' => 'public',
]
However, he discovered other problems in config/voyager.php:
'assets_path' => '/vendor/tcg/voyager/assets',
... where it too appears to be missing PhpstormProjects/Search4Venues from the path:
http://localhost:8888/vendor/tcg/voyager/assets/images/bg.jpg
At this stage, we have no idea what else could be wrong with Voyager.
Firs u need edit file .env:
APP_URL=http://localhost
to:
APP_URL=http://yout-site-url
After that u need edit the file fylesystem.php like this:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/public/storage',
'visibility' => 'public',
],
I was helped
Follow these steps:
1.Change APP_URL in the .env file to your website url.
For example:
APP_URL=http://localhost
to
APP_URL=http://127.0.0.1:8000
2.Create symbolic link by: (if not done yet)
php artisan storge:link
3.Restart your server (must. Otherwise chages will not be applied.)
this is common problem that even official site of voyager is mention about just read this page https://voyager-docs.devdojo.com/troubleshooting/using-https
in summery just open file filesystem.php in the folder config and delete this line of code 'url' => env('APP_URL').'/storage',
Update you .env file
APP_URL=http://localhost:8000
and then run
php artisan config:clear
last
restart your serve
this work for me.
This error sometimes usualy shown if we runing php artisan serve with default port like localhost:8000, but if you place laravel wit voyager in htdocs/www in your own server like xampp/mamp etc this error will gone,
So you can try :
Installing apache or stand alone webserver like wamp or mamp
place your project in htdoc/www folder, and don't forget to set .env app_url:localhost (or your domain without port)
change document root in apache config to your project folder
acces http://[your_domain]/[your_project]
done..
thank's
Updated .env file:
APP_URL=http://localhost:8000
Fixed issue
dont forget to restart the server
Updated .env file:
APP_URL=http://localhost/voyager
And Updated filesystems.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage/app/public',
'visibility' => 'public',
],
All you need to do is change in .env
APP_URL = http://localhost
to
APP_URL = http://<whatever your site is called>
And then move to the pic files to
public users
For some reason voyager stores them in
public users\users
At least it did for me
Just check what URL Voyager creates for the avatars and move them into the public folder with the same URL.
Worked for me at least
Change one line in .env file:
APP_URL = http://localhost
to
APP_URL = http://<your site url>
The command is used to remove the configuration cache file and created again.
php artisan config:cache
if you using laragon, change
'url' => env('APP_URL').'/storage'
to
'url' => env('APP_URL').'./storage'
I'm using Laravel 5 but I'm not being able to migrate my database table. I have a macbook pro and I'm using Terminal. I'm using php artisan command:
php artisan migrate.
When I execute this command, I get the following error message: [PDOException]
SQLSTATE[HY000] [2002] Connection refused.
I have configured my database.php following the official tutorial videos on laracasts.com. My database.php file looks like the following:
...
'fetch' => PDO::FETCH_CLASS,
...
'default' => env('DB_CONNECTION', 'sqlite'),
...
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => database_path('database.sqlite'),
'prefix' => '',
],
....
I have read many comments on stackoverflow.com about this issue. Most of them are talking about modifying the ".env" file. The thing is I can't find this file! Which makes me wonder if my installation of Laravel is complete or not! I read that my ".env" file might be overriding my "database.php" file but I can't file the ".env" file!
The env file is most likely hidden.
Run defaults write com.apple.finder AppleShowAllFiles YES and Killall Finder in Terminal.
Open Finder and you should be able to see the .env file.
Edit your .env file.
I would like to add sqlite db to my lumen app but I have some troubles.
I create migration:
php artisan make:migration create_users_table --create=users
then I changed my .env file, so it looks like:
DB_CONNECTION=sqlite
DB_HOST=localhost
DB_DATABASE=database.sqlite
then I was created database.sqlite and put it in storage folder and when I 'm trying to do:
php artisan migrate
I have
[InvalidArgumentException]
Database (database.sqlite) does not exist.
I uncommented this lines in bootstrap/app.php:
Dotenv::load(__DIR__.'/../');
$app->withFacades();
I can't find what is wrong.
I work on ubuntu 14.04
In my .env file I changed to:
DB_CONNECTION=sqlite
# DB_HOST=localhost
# DB_DATABASE=database.sqlite
I left only
DB_CONNECTION=sqlite
So Lumen use default config from /vendor/laravel/lumen-framework/config/database.php. It works.
According to lumen-framwork/config/database.php
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', storage_path('database.sqlite')),
'prefix' => env('DB_PREFIX', ''),
],
sqlite is the default setting for lumen.
And you can set DB_CONNECTION in .env as follows:
DB_CONNECTION=sqlite
Then lumen will use storage_path('database.sqlite') as storage/database.sqlite
Otherwise, if you would like to assign DB_DATABASE directly, you should give the full path:
DB_DATABASE=/Users/../../storage/database.sqlite
Step 1 : Open .env file & replace respective database configuration with following piece of code.
DB_CONNECTION = sqlite
#DB_HOST = 127.0.0.1
#DB_PORT = 3306
#DB_DATABASE = homestead
#DB_USERNAME = homestead
#DB_PASSWORD = secret
Note : lines those are started with # are basically commented code.
Step 2 : Create a new file, name it database.sqlite in database folder. It will store out database structure.
Step 3 : There is need to include this file as ignored in our versioning system as there will be so many changes are going to be made with database i.e. insert, delete, update etc. To ignore database.sqlite, Open .gitignore file, and add this line at the end database/database.sqlite. (i.e. path of database.sqlite file).
I'm try use a sqlite database in my laravel project, in local environment for dev (Windows 8.1 with AMMPS), but when I try run a migrate:instal command, this error apeear:
[PDOException]
SQLSTATE[HY000] [14] unable to open database file
My database config file (app/config/local/database.php):
<?php
return array(
'default' => 'sqlite',
'connections' => array(
'sqlite' => array(
'driver' => 'sqlite',
'database' => __DIR__ . '\..\..\database\production.sqlite',
'prefix' => '',
),
),
);
try to remove the DB_DATABASE="yourdatabase" variable in your .env file
If the permissions allow to write on the folder just create the storage folders.
e-g, this how I fix the problem.
in config/database.php :
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => storage_path('database/databaseName.sqlite'),
'prefix' => '',
],
Then if you run on your terminal php artisan migrate, it returns you the [PDOException] SQLSTATE[HY000] [14] unable to open database file
Create the path folder by your own, e-g in your terminal mkdir storage/database/databaseName.sqlite
Make sure the permissions allow you to write, then re-run the command php artisan migrate, it returns you the success message : Migration table created successfully.
On laravel 5.3.x
This was the only thing that worked for me:
Change DB_CONNECTION from "mysql" to "sqlite". Because this is an
sqlite database, you can delete all the other DB_* items in that .env
file.
APP_ENV=local APP_KEY=base64: APP_DEBUG=true APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=sqlite
You just need to make sqlite file available at the defined path. In larvel 5.7, I just used following command and run migration.
touch /absolute/path/of/db.sqlite
That will create an empty file at defined location and you are good to go.
Observation: In Larvel 5.7, .sqlite file should be already available at defined location.
For windows, right click and create new file with the defined name at defined location.
try change the file databaseName.sqlite permission database to writeable and readable. Maybe change permissions folder database also.
In the production server change this file database to private directory for security.
Well it may be late but I have also faced the problem in ubuntu environment, here exactly how I overcome this issue.
You have to pass your fully qualified sqlite file's path to your .env file, like following:
DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE="/var/www/html/my-awesome-project/database/database.sqlite"
DB_USERNAME=homestead
DB_PASSWORD=secret
Here change the value of DB_DATABASE key to the exact location of your sqlite file in your computer's filesystem.
Tips:
You can find your database's path for sqlite file by adding
dd(database_path('database.sqlite'));
this line of code in the top of config/database.php file and run php artisan migrate to terminal. You can find the exact location from there, copy it and put it to .envs DB_DATABASE key.
Don't forget to restart laravel server and remove dd(database_path('database.sqlite')); form database.php before testing.
In my case, changing url: '%env(DATABASE_AUTH_URL)%' to url: '%env(resolve:AUTH_DATABASE_URL)%' fixed the issue
Please check the permissions of the directory that database file is stored in. chmod 777 YOU_APP/database
Change DB_CONNECTION from "mysql" to "sqlite".
Because this is an sqlite database, you can delete all the other DB_* items in that .env file.
APP_ENV=local
APP_KEY=base64:
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=sqlite