Desperately looking for a non empty $_ENV in Laravel - laravel

I have a console task ran through:
$schedule->command('process:job')
->cron('* * * * *')
->withoutOverlapping();
The task is run, it can invoke different services, everything is fine in the world. However I have one specific tasks invoking a different class where the configuration is not loaded.
For specific reasons I wish to read my configuration in $_ENV (it allows me to do some key value iteration and process some keys specifically based on a pattern). But here $_ENV remains empty, I can read configuration through config() or env().
This never happens through HTTP calls nor through some command lines call (I haven't been able to understand the difference in the scheduler call and command line invocation).
Laravel 5.6
EDIT: this question is kept here because I didn't manage to find the existing relevant one Why is my $_ENV empty?

Found my solution here: Why is my $_ENV empty?
Basically $_ENV is not populated on a systematic basis but only if the flag E is in your variables_order ini variable. So if you stumble one the same problem, I suggest a quick check.
var_dump(ini_get('variables_order'));
The fix is obviously to fix your ini file.

Related

Strange behavior in Laravel 7.2 Illuminate\Foundation\Http\FormRequest

I have a project with a fairly standard Dev-on-Homestead to Staging to Production workflow. All are using Laravel 7.2.2/Ubuntu 18.04/PHP 7.4.3
This cropped up today with some form requests.
Symfony\Component\ErrorHandler\Error\FatalError
Type of App\Http\Requests\CreateHighlight::$errorBag must be string (as in class Illuminate\Foundation\Http\FormRequest)
This is a named $errorBag that we've been using since 5.4 or so?
I changed the $errorBag to protected string $errorBag='highlightCreate'; and proceeded to test and deploy.
That same code kicked this back from the staging error logs:
staging.ERROR: Type of App\Http\Requests\CreateHighlight::$errorBag must not be defined (as in class Illuminate\Foundation\Http\FormRequest)
I have checked and rechecked and checked a fourth, fifth, sixth time. Everything appears to be identical between the two environments, yet I cannot for the life of me understand why this is happening. They're the same error except they're contradicting each other.
Based on FormRequest it clearly seems like errorBag is not defined as a string. This clearly seems like it is something with your local file there is wrong. Never the less the errorBag should not be defined as a string.

Spring boot: Override property value

Into my application-pre.properties file there's coded this property:
scheduler.url-backoffice=http://${BACKOFFICE_SERVICE}:8080
In order to fill it, I'm using -Dspring-boot.run.arguments=--spring.config.additional-location=scheduler-config.properties.
scheduler-config.properties:
BACKOFFICE_SERVICE=localhost
scheduler.url-backoffice=http://localhost:8081
I need to set BACKOFFICE_SERVICE property, otherwise spring doesn't start. So, it means that scheduler.url-backoffice comes to http://localhost:8080.
I 've added another line after that in order override its value.
My surprise is its value is not changed. I mean, scheduler.url-backoffice's value is http://localhost:8080 instead of http://localhost:8081.
I'm not able to change application-pre.properties content file.
Use multiple application properties files.
One can ship in the jar;
this contains the defaults.
For me, defaults translates to either the prod values,
if there is only one set of prod values,
or the developer local values (which should cause failures in production).
The second file contains the environment specific property values that
override the defaults.
You must change your startup values to achieve this.
Here is an example:
-Dspring-boot.run.arguments=--spring.config.additional-location=scheduler-config.properties,local-scheduler-config.properties
Edit: in response to "still not working".
It seems like you need much more than the "simple" approach I described above.
For that,
check out section 24. Externalized Configuration in the Spring Boot Reference Guide.
There are many techniques to override configuration values;
all are covered in the reference guide.

How do I access this variable from a different blueprint?

I have found loads of stuff like this on the Internet, but none of it is helping me and I would just love a direct response for this situation.
I have a text UI for my ammo which I simply want to access from the blueprint that handles firing. The text UI has a variable associated with it (At least, I assume this is my text UI):
But for unknown reasons won't let me make it public. That doesn't seem to matter though, because I have experimented with other public variables and I can't access them from my blueprint either!
How can I get access to my variable here so I can do what I wish?
I found your other questions so I assume you're using 4.12, like myself.
So I can use the variable declared in UMG as follows:
Step 1, make a text block, enable it as Is Variable:
Step 2, check it from the Graph part:
Step 3, some other Blueprint, use it:

distinguish use cases in NSAutosaveElsewhereOperation

I try to add AutoSave support to the Core Data File Wrapper example
Now if i have a new/untitled document writeSafelyToURL is called with the NSAutosaveElsewhereOperation type.
The bad thing is, I get this type in both typical use cases
- new file: which store a complete new document by creating the file wrapper and the persistent store file
- save diff: where the file wrapper already exists and only an update is required.
Does somebody else already handled this topic or did somebody already migrated this?
The original sample use the originalStoreURL to distinguish those two use cases, which solution worked best for you?
Thanks

How can I view information about a variable or array in symfony 1.4

I am trying to learn symfony framework by creating a small project.
Since I started developing the project I have been wondering if there is a convenience function to see the contents or information of a variable or array anywherea in the application by print_r or echo or var_dump (I can use the aforesaid function straight away anywhere in the application but the output is not properly readable in case of large arrays, moreover there are warnings showin like header already sent etc. etc.).
I have also used cakePHP and it has a convenience function named pr() which prints out the contents of variable or array nicely indented (properly readable).
If I had to create such function than how can I make sure that it can be called anywhere in the application?
Any tips (links/blogs/tutorials) related to "how to debug your symfony applications" are greatly appreciated.
To put it simple: you can't output debug "things" in your controller. The controller has nothing to do with the View (output), so when executing it does not know if there's going to be any output.
But, you can output debug "things" in your controller ;-)...
Just print_r() or var_dump(). And immediately die afterwards. That way you can see your debugging.
Call the logger. $this->getLogger()->debug($message);
Add a custom slot which you assign in your controller ($this->getResponse()->setSlot('debug', $debugData)). And include this slot somewhere in your layout file (preferably only in the dev environment.)

Resources