I have a project with Laravel version 7.28. I run
composer require barryvdh/laravel-debugbar --dev,
After that I added Barryvdh\Debugbar\ServiceProvider::class to app/config.php under providers and added
'Debugbar' => Barryvdh\Debugbar\Facade::class
to app/config.php under aliases. Then I run
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
Even though APP_DEBUG in .env is true and I terminated and rerun the app debugbar is not showing. Where did I make my mistake?
I checked the config/debugbar.php, I see the new key DEBUGBAR_ENABLED with default is false. Then add it to .env file: DEBUGBAR_ENABLED=true
Make sure you are running on right port. I had php backend (running on port 8000) and react frontend (running on port 3000) and I did everything you have described above but it never worked. The issue I had was that I was checking if the debugbar showed up on port 3000 (which it never did sadly). I went to check on port 8000 and the debugbar was sitting there the whole time.
I didn't end up using the php debugbar because I think it only works if your frontend code is written in php (though not 100% sure).
I ended up debugging using postman. It doesn't have all the functionalities that the debugbar offers but it is a great tool to use if you just want to do basic debugging.
Related
i finish my laravel project and push it to my VPS.
so at some point am sending email message to admin. but laravel is giving me null for env
Mail::to(env("ADMIN_EMAIL"))->send(new NewOrderAdmin());
i tried to set the ADMIN_EMAIL in config app.php and call it from there
config(app.ADMIN_EMAIL)
but still giving me null. and this is only on production for some reason
I have checked my .env and tried to clear cache but still no result
you need to clear your config cache so
run php artisan config:clear
I'm completly new to Symfony and tried the following guide: https://github.com/thecodingmachine/symfony-vuejs ... but without docker (I have a simple webspace, I can't use docker there).
Now I'm stuck right in the beginning, when calling composer install in the app root. I get the following message:
In EnvVarProcessor.php line 131:
Environment variable not found: "DATABASE_URL".
Well, that sounds easy, I have to setup an enviroment variable ... but I'm not using docker and I don't want to set up a temporarly variable in the shell. Few seconds of google helped me, that I can use .env for my problem like descriped here: https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables
In the example project is already a .env file, so I extendet it by DATABASE_URL. But suddenly it is not taking that variable.
I'm working on a macbook with a simple apache/php setup without forther configuration.
What am I missing?
How could i link Laravel log files to PaperTrial ?
According to this article :
http://mattstauffer.co/blog/laravel-forge-logging-with-papertrail#step-4-add-a-syslog-handler
I followed steps and reached to step 4 putting Syslog Monolog handler in the /app/route.php file ,went to PaperTrial dashboard but i didn't see any output.
Any help ? thanks.
For Laravel 5.1 after setting up the forge, you should add to bootstrap/app.php file the following code just before the return of the $app variable
$app->configureMonologUsing(function($monolog){
$monolog->pushHandler(new Monolog\Handler\SyslogHandler('papertrail'));
});
return $app;
The parameter (in this case 'papertrail') can be whatever you want to, this name will show on the papertail's event screen.
I have it working using the standard logging facility instead of Monolog. This way there is nothing extra to install. Just add this to rsyslogd's conf:
### Laravel Log
$InputFileName /path/to/vhost/dir/app/storage/logs/laravel.log
$InputFileTag laravel-errors-domain.com:
$InputFileStateFile state-laravel-errors-domain.com
$InputFileSeverity error
$InputRunFileMonitor
And make sure that this log gets included in the send action, if you are not sending everything.
Then issue
service rsyslog restart
From my experience using Laravel 5.2.* with Forge, Step 4 from that article is not necessary anymore. All you have to do after Step 3 is set your Environment .env settings in Forge to APP_LOG=syslog for each site you want to use with papertrail.
However, this means that Laravel will not log to laravel.log anymore in this environment. But, in other environments (e.g. dev environment) you could of course continue logging to laravel.log by simply not making any changes to the .env file there.
I have a fresh install of Laravel. When running php artisan migrate:refresh I get a message saying Application In Production! Do you really wish to run this command?'
I know this is an update in 4.2, however I can't figure out how to turn it off.
I found in the source that it comes from Illuminate\Console\ConfirmableTrait and runs if this if test passes : if ($this->getLaravel()->environment() == 'production')
I'm not sure why it thinks I'm in production. I never setup any environments. This is the default environment detection, which I'm still currently using.
$env = $app->detectEnvironment(array(
'local' => array('homestead')
));
Also, if I set a production environment to a hostname that isn't my machine, I still have the same problem.
Just specify a machine name for the host that matches a given environment, then laravel will automatically detect the environment (default is production), for example:
$env = $app->detectEnvironment(array(
//'local' => array('homestead'),
'local' => array('*.dev', gethostname()),
'production' => array('*.com', '*.net', 'www.somedomain.com')
));
Read the documentation and this answer as well.
Setting your environment to something other than production is The Right Way. See the accepted answer.
But, if you're looking for A Quick Fix you can use (in UNIXoid environments):
yes | php artisan migrate:refresh
All this does is send a stream of "y" to the program, which acts like you pressed "y" when prompted.
I find this to be a little better than --force, as not all the artisan commands support force.
In case if anyone stumbled upon this question while searching for similar problem in a lumen installation I'd suggest to check the .env file and add APP_ENV=local if its not already there. It solved my problem.
Hopefully this will help someone else. I suddenly had an issue where my dev site I was building stopped connecting to the DB saying:
PDOException SQLSTATE[HY000] [1049] Unknown database 'forge' failed
I was also receiving errors such as the OP when trying to run artisan migrate:refresh etc, the error was stating that i was in production etc etc.
After much head scratching (!) I found that my hostname value set inside the /bootstrap/start.php was wrong, because my hostname had changed on my macbook pro!? I have no idea how but it changed from something like RobMacbookPro2.local to RobMacbookPro.local. This meant it fell back to production thus loading the incorrect database.php file with the standard DB=forge (which was wrong)
Check this guide:
http://laravel.com/docs/4.2/configuration
Pay particular attention to the code:
<?php
$env = $app->detectEnvironment(array(
'local' => array('your-machine-name'),
));
On a mac and probably linux? you can determine your hostname by typing # hostname in terminal.
Hope that saves someone some time!
On first thought, this may seem unnecessary, as we have defined providers in config/app.php to autoload any ServiceProvider, but it turns out there is a scenario where they will NOT be autoloaded:
When we run a job from Laravel Queue - it would seem my ServiceProvider in config are ignore completely, so DI failed with target ... is not instantiable.
Register my service providers at runtime in the job does work. e.g.
App::register('MyServiceProvider');
Is there a reason that Laravel did not autoload my ServiceProvider in such case?
PS: I opened an issue on github as well, as I am not if this is by design.
If you define your environments by URL, those environments will not be automatically recognised from the command line - I've run into this issue myself when trying to run migrations/seeds.
You can define environments in any way you like since the environment definition accepts a closure but 'out of the box' you can return a regex that matches wither a machine name or a url. examples here - environment config.
One solution would be to define your service providers in the app.php at the route of your config (this is the default config and will be used if no other environments are recognised from the command line) OR if you need different settings for different environments you could try defining your environments by machine name - this is the hostname of your machine - on a unix box you can see what this is with echo $HOSTNAME on the command line.
Another solution from OP
As the OP has discovered, artisan accepts --env flag on just about every command which allows you to force an environment, so you can call php artisan queue:work --env=local to force it to use the local config when working queues.
Hope this helps