I have project in Laravel 6 with MySQL database and its working fine. My client wants to use SQLite instead of MySQL database.
So i converted my existing database from database.sql to database.sqlite using following online tool
Online database conversion done here : https://www.rebasedata.com/
https://www.rebasedata.com/convert-mysql-to-sqlite-online
After that i have configured database.sqlite into .env file and into config/database.php file.
Issue : I am not able to go beyond login page. Every time i try to login it redirects me back to login page.
Debug : I reviewed that if I remove Authentication function then i am able to access controller which comes after login.
If I do comment to this line $this->middleware('auth'); following function It starts working.
public function __construct()
{
// $this->middleware('auth');
}
Conclusion : I found that I am not getting any value for $user = Auth::user();
So I think that session is not getting generated and stored correctly with SQLite database
Notes :
I have exported existing database using phpmyadmin and removed all
unnecessary comments from database.sql file.
I converted database.sql file online using this tool
https://www.rebasedata.com/convert-mysql-to-sqlite-online
As per my investigation Auth is not getting generated and stored.
I am using default laravel Auth, I generated that using laravel terminal command.
This setup works fine if I configure project with MySql database.
SQLite database configure Path is correct. I found error of not proper path while configuring it and i solved that.
I have already tested using this commands. : php artisan cache:clear --- php artisan route:cache --- php artisan config:cache --- php artisan view:clear
Any help are appreciated. Thanks in advance.
Related
I am using the ready package as a base, I have done all steps in the readme.md file and was able to login as "einstein" user. So all seems to be configured correctly.
Later I have changed the credentials for the ldap server, which is using Active Directory.
While runing command php artisan ldap:test i receive message that i was able to connect correctly. Laravel logs says the same, but I cannot log in to laravel app. While running the command php artisan ldap:import ldap get message that no users where find
In the log file i see something like this:
[2021-04-28 23:04:08] local.INFO: LDAP (ldap://domain.pl:389) - Operation: Search - Base DN: cn=username#domain.pl,ou=Users,dc=domain,dc=pl - Filter: (&(objectclass=top)(objectclass=person)(objectclass=organizationalperson)(objectclass=inetorgperson)(uid=username)) - Selected: (entryuuid,*) - Time Elapsed: 737.37
Have anyone had the same issue with the ldaprecord that he was able to connect to domain but wasn't able to authenticate to an app ? And was able to solve that ?
UPDATE: i've found that auth.php is using wrong User model, it was using OpenLdap not Active directory, changed that but result is still the same
Problem solved, to make it work with AD you need to:
in the auth.php file switch model to ActiveDirectory
in login controller change in the credentials function have to change 'uid' key to 'sameaccountname'
I am trying to send email to user for forget password using rest API,
here is my controller:
enter image description here
strong text
put when I call this forget function by my Api on postman it gives this error :
'laravel.password_resets' doesn't exist
how can I solve this issue
Please run
php artisan migrate
There is a possibility that your would have dropped the database table.
Php artisan migrate: fresh
Prerequisites
In my local environment I am working with multiple tenants and Redis (Auth required).
To serve the project I am using Valet.
For this case I am addressing these two connections:
- basic_foo (is defined in my .env)
- tenant_foo (is the one to change to during a request)
Until now I successfully changed the connections like so:
config()->set('database.connections.mysql',
array_merge(
config()->get('database.connections.mysql') ,
['database' => 'tenant_foo']
);
Problem
However, now I am seeing an issue with the query builder, keeping or falling back to the basic connection.
I get the expected connection results of tenant_foo (same for Redis) when I run
dd(config()->get('database.connections.mysql'));
I get the wrong but apparently active results of basic_foo when I run
dd(\DB::connection()); // returns Illuminate\Database\MySqlConnection
So all in all the app will return this Illuminate\Database\QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'basic_foo.table_bar' doesn't exist...
where it should search for
'tenant_foo.table_bar'
Things that did not solve the problem yet
restarting Redis
reinstalling Redis
php artisan config:cache
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan optimize
composer dump-autoload
Simply changing the database name to tenant_foo like below is not enough, as the config array remains the same of basic_foo.
\DB::connection()->setDatabaseName('tenant_foo');
Thoughts
I want to change the config-array the of \DB::connection(), but I don't know another way than the config->set().
I installed Telescope could this affect the db connection?
Any other ideas?
To dynamically change database name you should use:
DB::disconnect();
Config::set('database.mysql.database', 'tenant_foo');
DB::reconnect();
This worked for me:
\DB::disconnect('mysql');
Config::set('database.connections.mysql.database', 'tenant_foo');
\DB::reconnect('mysql');
I'm using the following multi tenancy package:
https://laravel-tenancy.com/docs/hyn/5.3
Laravel: 5.7
I current made the caching tenant aware by changing the config on the switched event.
Event::listen(Switched::class, function (Switched $event) {
config(['cache.stores.file.path' => storage_path('framework/cache/' . $event->website->uuid)]);
});
This works well when doing a command like:
php artisan tenancy:run my:caching-command --tenant=2
This does not work well:
php artisan tenancy:run my:caching-command
In this case only a cache dir is created for the first tenant. When debugging it, I found that the config is actually properly updated for each tenant. However the cache driver is not using the new path...
Anyone any ideas?
I needed to rebuild the cache instance with:
app()->forgetInstance('cache');
If lateron in your code the cache instance is accessed via app('cache'), it will be rebuild with your current config.
I already asked a question about this 2 days ago, here are the links
Got "password authentication failed for user" but in pgAdmin 3 its working
But I still didn't get an answer to solve the problem.
So I tried to create a new laravel project, then edit the .env file, check if php artisan migrate can run.
After I run php artisan migrate it's running, so it means that my credentials to PostgreSQL database are correct right? if not it will tell you password authentication failed for user "postgres", but I don't get any error at all, so I go to the next step. Now after I make sure everything is OK i run php artisan make:auth, it's a success without error at all, so I go to the web browser then run the site, I clicked the register / login button, fill the fields, submit then, it's happened again the nightmare
I got this message from the website
SQLSTATE[08006] [7] FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres" (SQL: select count(*) as aggregate from "users" where "email" = test#test.com)
Even though php artisan migrate run really well, so I've no idea why it's happening. Is there somebody that ever run into this problem before? or maybe why it's happening?
I already search all keywords that possible to fix this problem, but I can't found the answer, it's really stressed me out.
for the info I'm using:
PostgreSQL 9.6.8
Laravel 5.6
Ubuntu 17.10
Edited: Here is my pg_hba.conf
Check your database.php file in config directory, and check the pgsql array. If accessing DB credential values from .env not worked there, test it by directly putting credentials there. hope it will help. Artisan commands work by accessing the credentials from .env files directly,not from database.php that's why migration worked.
I had a similar problem, my generated password contained the character: '#'. This made it a comment line, ignoring the rest of the password. I just changed my password.