Laravel - queue driver database not working - laravel

In my laravel app I have set up table for jobs in my database, and setup the .env file with database driver, I run php artisan queue:work in terminal, but nothing gets uploaded when I try to upload it like that, but when I use sync driver everything works fine.
Not sure why is that and how to fix it so that it works with database driver?

I your terminal run the following
php artisan config:clear
php artisan config:cache
Sometimes when a value is changed in your .env file, you might have to run the aove listed commands for them to take effect. It worked for me

To process new jobs you need to run:
php artisan queue:work
in console as mentioned in Queues documentation

Related

Creating Schema automatically using migration in Laravel

Is it possible to create schemas automatically in the database when xampp is turning on? There is no information about it in the Laravel documentation, documentation says only how to do it manually by writing the command php artisan migrate.
Xampp includes a script called apache_startup.bat in the root directory, you can add the following line to it
c:\xampp\php\php.exe -f /path/to/laravel/app/artisan migrate
Then when the apache server starts, it should run that the equivalent of php artisan migrate to setup the database.
You can do php artisan make:migration [migration-name] - other than that, you have to fill the rest yourself.

127.0.0.1:8000 keeps on loading in a laravel project

I have a laravel project but when I use the command "php artisan serve" and type the url: http://127.0.0.1:8000/ , its just keep on loading without output nor error appear.
I solved this by running this command instead of PHP artisan serve.
php -S 127.0.0.1:8000 -t public/
Then try to load again 127.0.0.1:8000 in your browser.
Try disabling your anti-virus or check your firewall.
I disabled my Avast anti-virus and it's working fine for me now.
The port 8000 might be used by other in your computer. Try to change port by running in your project in cmd:
php artisan serve --port=1000
then type http://127.0.0.1:1000/ on your browser.
Run commands
php artisan config:clear
php artisan config:cache
Even after completing these steps, if Laravel is still showing error, check your_project/storage/logs/laravel.log.
Try these three commands for clearing cache config:
php artisan config:cache // clear config cache
php artisan config:clear // clear config cache
php artisan cache:clear // clear cache
php artisan optimize // To reoptimize the class loader
php artisan route:cache // clear route cache
php artisan view:clear // clear view cache
It sometimes happen because of too many redirection and also sometime because of middleware . so see your whole flow for that page.
Also see your cdn which included in your page because it take too many time if you have too many cdn and your connection is slow. And also try to clear all cache.
I experienced this problem also when I first launched out into Laravel.
Your port 8000 is most likely occupied by another service or program.
Simply go to your terminal where your project is open, and enter the following command
php artisan serve --port=1000
Then, return to your browser and enter the address, replacing 8000 with 1000, as in
127.0.0.1:1000
This worked for me.
There are several issues may be possible for that.
You have used CDN JS and CSS
Check you route/web.php
Check you log error log file storage/logs/laravel.log
Check above points this will sure give you positive result.
In my case I uninstalled Xampp and reinstalled it(I'm assuming you are using Xampp too).It worked for me.
If you are using xampp
just restart Apache and MySql

Laravel Serve command does not respect --env parameter

To be able to run Browser tests directly in my IDE (without using the artisan dusk command), I want to run php artisan serve --env=dusk.local. While it indeed starts the local PHP server, it uses the wrong database. It uses the database specified in .env not the one in .env.dusk.local.
I ran php artisan cache:clear thousands of times, but it doesn't change anything.
Running things like php artisan migrate --env=... works.
Is there a way to achieve my goal without needing to rename my .env.dusk.local file to .env before each test?
This is a bug in Laravel 5.8: https://github.com/laravel/framework/issues/27828
There is currently no solution (other than downgrading to Laravel 5.7).
It has been fixed in the latest release 5.8.7.

Not work "Migrate" and mysql in laravel project

I install laravel and create project.
I Configed configuration file database and create database in mysql(mysql runnig in wamp server).
I want use migrate for create table in mysql,but i should wait a lot of time and see error.
What shoud i do?
This could help you run these command in terminal:
php artisan migrate --force
The migrate:refresh will roll back all of your migrations then execute the migrate command.this will re-creates your entire database.
php artisan migrate:refresh
This will absolutely help you,run this command:
php artisan migrate:fresh
if it did't help please chick out this:
https://laravel.com/docs/5.7/migrations
Probably you entered your mysql Server credentials in the database config, but you have to edit the .env file. Values in there overwrite config settings.

Laravel Dusk ignores .env.dusk and .env.dusk.local (Using Valet and Laravel 5.5)

I'm trying to run Laravel Dusk and I need to use a test database. When I check the screenshot it says that the database doesn't exist. Problem is that is the database defined on .env and not the one on .env.dusk ... I've tried to rename the file to .env.dusk.local and still no luck. What am I doing wrong?
Try clearing your cache? I remember having similar issues when I first started using dusk.
php artisan cache:clear
I got the same problem. Lately I figured out that the .env file is being cached before dusk start.
I resolved it by adding
$this->artisan('config:cache');
into the createApplication() function in CreateApplication.php. It works :)
But then, if I finished the dusk test, I must run
php artisan config:cache
to get the original server running.
Edit:
later I tried simply call the
php artisan config:clear
also prevent the application caching the env variable. (Much simpler and faster)
I was able to get this to work by following these steps:
Remove .env.testing
Run php artisan dusk (This will create phpunit.dusk.xml).
Add the following to the end of this newly created file
<phpunit>
...
<php>
<server name="APP_ENV" value="local"/>
</php>
</phpunit>
You can now restore .env.testing which can still be used for phpunit testing.
ORIGINAL ANSWER
I found that if you remove .env.testing it then uses .env.dusk.local. It seems that .env.testing always take precedence.
This does not solve the problem of using a separate .env for unit tests & dusk; which is useful when running unit tests in memory and dusk tests using sqlite.
Same issue... The problem is you forgot to create config cache file for your testing env so dusk will use your current local config cache file instead. Here is the fix:
1/ duplicate .env to .env.dusk.testing and edit the following:
APP_ENV=testing
DB_DATABASE=halfwish_test #I use different MYSQL database for testing.
2/ run this cmd:
$ php artisan config:cache --env=dusk.testing && php artisan clear //clear compiled services and packages files and cache config file.
$ php artisan migrate:fresh --env=dusk.testing && php artisan seed --env=dusk.testing //this is migrating and seeding demo data to DB.
Now you can run php artisan dusk.

Resources