Warning: date_default_timezone_get(): - symfony

I have researched all the answers I can find for this and have had no luck getting it to work.
I am getting the following error when I try to run symfony.
Warning: date_default_timezone_get(): It is not safe to rely on the
system's timezone settings. You are required to use the
date.timezone setting or the date_default_timezone_set() function. In
case you used any of those methods and you are still getting this
warning, you most likely misspelled the timezone identifier. We
selected the timezone 'UTC' for now, but please set date.timezone to
select your timezone. in /symfony_project/app/cache/dev/classes.php
line 5229
I have checked the following :
php --ini
Configuration File (php.ini) Path: /etc Loaded Configuration File:
/etc/php.ini
I have changed the ini file to date.timezone = "Europe/Dublin"
restarted apache
Cleared the cli cache
cleared the browser cache
Ran phpinfo and confirmed the
loaded config file is etc/php.ini
Additional .ini files parsed (none)
date.timezone = "Europe/Dublin"
I also ran echo date_default_timezone_get() in the browser and I get Europe/Dublin
I am running PHP v 5.4.24 (for what its worth)
I ran echo date_default_timezone_get() inside
which returns UTC ... so it looks like symfony is not reading the php.ini file properly.
Not sure what else I can do.

find your php.ini file path
php -i | grep php.ini
edit php.ini date_timezone set it is your timezone
time_zone = "Asia/Shanghai"
restart your nginx and php-fpm

Related

How to handle the "wildcard" * asterisk on a Windows Command

Using
Windows
Local by Flywheel
Composer (task runner)
Working on a Child Theme to a Custom Made "Core" theme.
I'm running composer install on the root of my WP directory to install dependencies on a parent and child theme.
Problem is when the installations are running it errors out when it gets to the src/*.js. I asked the team that set up the page and they told me that it was a problem with how Windows handles wildcard characters, which I understand it as the asterisk* and that they solved it in the pass by getting their employee a Mac. Since these dependencies are not going through, there's files that aren't loading on the website.
Getting a Mac, to solve this issue, is not on the table, so I'm looking to figure out what other options do I have to run this command successfully on a windows?
I tried going directly to the src/ folder and running npx wp-scripts start src on each .js file individually, and it gave a "successful build" message each time, but that didn't fix the issues on the page.
> wp-scripts build src/*.js
assets by status 95 bytes [cached] 2 assets
Entrypoint * = *.js *.asset.php
ERROR in *
Module not found: Error: Can't resolve './src/*.js' in 'C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName'
resolve './src/*.js' in 'C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName'
using description file: C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\package.json (relative path: ./src/*.js)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js.wasm doesn't exist
as directory
C:\Users\UserName\Local Sites\localSiteName\app\public\wp-content\themes\parentThemeName\src\*.js doesn't exist
webpack 5.64.1 compiled with 1 error in 149 ms
Script cd wp-content/themes/parentThemeName && npm install && npm run build && composer install --no-interaction --ansi --ignore-platform-reqs handling the install-core-deps event returned with error code 1
Script composer install-core-deps && composer install-child-deps handling the post-install-cmd event returned with error code 1
Thanks for any and all help.
Cheers!

The openssl extension is required for SSL/TLS

I try to run this command
> symfony new my_project_name
But it gave me this error.
[Composer\Exception\NoSslException]
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.
You may need to activate openssl in your php.ini.
To find your current php.ini file execute this command php --ini
Then add this line
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
...
extension=openssl <---
Restart php services (task manager > CGI / FastCGI > End task) to be sure to apply modification.
Also, be sure that the php_openssl.dll is inside of your php/installation/path/ext/ directory.
Example :

Symfony 2 When running Generate:Bundle it does not work

I am trying to add a new bundle using the console with the follow code...
php app/console generate:bundle
How ever it is giving me the following error...
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: date_default_timezone_get(): It is not safe to rely on the system'
s timezone settings. You are *required* to use the date.timezone setting or
the date_default_timezone_set() function. In case you used any of those me
thods and you are still getting this warning, you most likely misspelled th
e timezone identifier. We selected the timezone 'UTC' for now, but please s
et date.timezone to select your timezone. in /Users/Phil/Sites/SoccerTips24
/vendor/monolog/monolog/src/Monolog/Logger.php line 233
generate:bundle [--namespace="..."] [--dir="..."] [--bundle-name="..."] [--format="..."] [--structure]
I understand the first one is something to do with the time settings but then bundles wont add to my src folder...
Any ideas how to fix?
Set timezone in your php.ini
php -i |grep php.ini
uncomment timezone record, and set you timezone:
date.timezone = "Europe/Paris"
Once you go to your php.ini and set your timezone it should work.

ErrorException: Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /../../

I am trying to create my own authentication provider like in http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html.
But, it keeps saying:
ErrorException: Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /../../vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php line 56
Symfony2 sessions will not work properly with "session auto start" enabled. So make sure that's disabled.
Make sure your php configuration php.ini has this configured: session.auto_start = 0.
Or you can add php_flag session.auto_start 0 to your .htaccess file if you can not edit the php.ini file.
Additionally, there's one more possibility to get this error, as I found out after a long time of struggling:
For whatever reason, this crucial part was commented out in my config_test.yml, giving me exactly the same error:
framework:
session:
storage_id: session.storage.mock_file
The storage_id setting must be in place to avoid the problem.

Symfony 2 pdo exception

I'm using Symfony 2 and have this row in my parameters.ini:
database_driver = pdo_pgsql
When I was creating database structure with Doctrine everything was good. But if I want to add some doctrine object to my darabase (insert row), I catch an exception:
What I have to do with this?
Are you sure you're using pdo_pgsql? Are you running on localhost? It might be very certain that you are using pdo_mysql driver instead.
However you have to check the following:
php.ini
extension=pdo.so
extension=pdo_mysql.so
or in your case
extension=pdo.so
extension=pdo_pgsql.so
You can check the phpinfo(); to find out the configured database driver.
In your symfony project you have to check the parameters.ini file in config folder. E.g.
[parameters]
database_driver="pdo_mysql"
database_host="localhost"
Besides try to avoid this error
'stty' is not recognized as an internal or external command,
operable program or batch file.
https://github.com/symfony/symfony/issues/4974
First of all, verify your php.ini file: the extensions php_pdo_pgsql and php_pdo must be enabled. Make sure you apply this changes on php.ini file that your symfony project is using, check this on localhost/path_to_your_project/web/config.php. You know if this extensions are enabled executing the function phpinfo().
This command is also helpfull: php -m. It lists on console all the php modules that are loaded.
Tip: check out you Apache error log, there could be something wrong with the load of your extensions. This file is located according to your server configuration.

Resources