I use Laravel Telescope locally. It works very well.
In production, I disabled it but I noticed an error in the daily log file.
[2022-12-29 00:00:03] production.ERROR: There are no commands defined in the "telescope" namespace. {"exception":"[object] (Symfony\Component\Console\Exception\NamespaceNotFoundException(code: 0): There are no commands defined in the "telescope" namespace.
In the local log file, I don't have this message.
Thank you in advance for your help.
Delete
"laravel/telescope"
in composer.json
Looks like there's a command set to run at midnight that does something on Telescope.
Have a look at at App\Console\Kernel.php and see which commands are running at midnight.
If you need the command locally, but don't want it on production, wrap it in something like this:
if (config('app.env') === 'local') {
}
Related
I've deployed too many times Laravel projects up to Cloud Run successfully, but right now
It looks like Cloud Run is unable to read Enviroment Variables (which i've specified already in the Variables&Secrets section within Cloud Run instance).
I'm using Laravel 8. For testing purposes (and make sure Cloud Run it's reading env variables), i've added a simple route in the api.php section like belows:
Route::get('/test-env', function () {
echo 'debuggeando<br>';
dd(config('variables.test_env'));
});
Into my config/variables.php i've the follows:
<?php
return [
'test_env' => env('TEST_ENV', 'no se encontro la variable')
];
And this is my final result:
What do am I doing wrong? Why Cloud Run is unable to read the enviroment variables from Laravel?
You can only make Laravel pick up envirnmental variables, but not the other way around.
config(['test_env' => getenv('TEST_ENV')]);
Running php artisan config:clear & php artisan config:cache might be required. Another option might be to generate a fresh .env file during the deployment, which merely translates to: already defining the value, before it can be cached.
I have been trying to setup a Lumen application in Travis CI and i have found the following problem:
PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Dotenv: Environment file .env not found or not readable.
Given that this is triggered on phpunit execution i'm trying to load my environment variables from my phpunit.xml instead of a .env file but i don't know how to make it work
Any ideas?
Your .env file should not be checked into source control and as such you dont want to use it to run builds and on production. Therefore take advantage of using Travis CI to set env variables. Refer to https://docs.travis-ci.com/user/environment-variables/.
Dotenv was developed to be used on development environments only. It always expects .env to exist and will throw an error if it doesn't.
One workaround is to check for .env and only then load Dotenv. Here's a sample piece of code that you can use.
$dotenv_var = new Dotenv\Dotenv(__DIR__);
if(file_exists(".env")) {
$dotenv_var->load();
}
You can read up more on this issue here.
When I try php artisan serve command at my terminal it gives below error.Can any body help me to fix this issue?
ErrorException
The use statement with non-compound name 'App' has no effect
remove
use App;
from your route.php file, it will work for sure. Thanks.
I hereby post the answer for my own question as I found answer for this and hope this may helpful others in future.
Before : I just used 'use App' only at routes.php
Now : When use 'use App\Http\Controllers' problem solved.
Probably you add 'use App;' in some of your Laravel files, and artisan is parsing the line as an error.
To know which line/file is the error, go to the log file (storage/logs/) and check it out. Then remove that line from the file.
I have simple question on Laravel 5.1. I have created a controller using php artisan command:
php artisan make:controller PageSettings
However it was mistake, because I really wanted to create this controller in Admin folder like this:
php artisan make:controller Admin/PageSettings
Now I want to get rid of my old PageSettings controller. Is it ok just to delete my old PageSettings.php manualy? Or there is something more what needs to be done?
If you only created it and found that you did it wrong, you can manually remove the file and that's it. However when you already added routes to this controller in routes.php you should remove them from routes.php file or alter the file to reflect your new controller.
It is OK to manually delete controller. Just check routes.php if you have some route to that controller and delete it also.
I had an issue with just deleting the file. I tried running my PHPUnit test suite and got an error that looked like this:
Warning: include(): Failed opening '/user/home/me/some/file.php' for inclusion (include_path='.:') in /usr/home/me/some/vendor/composer/ClassLoader.php on line 444
I had to run composer update then composer dump-autoload. After that, everything worked just fine.
Yeah, you can delete manually without tension.
I will suggest you for avoiding more mistakes, you "phpStrom" software, from using this, if you delete manually any file from by click right of mouse->Refactor->safe delete then before deleting they will give all places which were using your file. by clicking "do refactor" you can delete it.
Whenever i try to run any php artisan commands from the command line, I get the following error(s):
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","me
ssage":"Call to a member function connection() on a non-object","file":"C:\\wamp
\\www\\cms\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Mod
el.php","line":2649}}{"error":{"type":"Symfony\\Component\\Debug\\Exception\\Fat
alErrorException","message":"Call to a member function connection() on a non-obj
ect","file":"C:\\wamp\\www\\cms\\vendor\\laravel\\framework\\src\\Illuminate\\Da
tabase\\Eloquent\\Model.php","line":2649}}
I have specified the Laravel version as 4.1.* in my composer.json but since i can't run artisan, i don't know the exact version.
This problem didn't use to happen before. And the website seems to be running fine, despite of the errors occuring in php artisan. Composer commands also work fine, as far as i can tell.
Any ideas why it is happening now?
This error seems to have happened, because for the mail configuration in app/config/mail.php, I made it to retrieve the values from the database instead of specifying the configuration options directly in that file.
So, I had to check if the function for getting the value is called from the web or from the command line. If the function is called from the command line, I simply returned an empty string.
if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
return '';
}