When running any magento commands - I keep getting a blank response then I check my error_log and see this:
[06-Oct-2024 12:21:33 Australia/Sydney] PHP Fatal error: Uncaught TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, bool given in /home/{{USERNAMEREMOVEDFORSECURITY}}/public_html/magento/vendor/magento/framework/Filesystem/DirectoryList.php:137 Stack trace: #0 /home/{{USERNAMEREMOVEDFORSECURITY}}/public_html/magento/vendor/magento/framework/Filesystem/DirectoryList.php(137): str_replace() #1 /home/{{USERNAMEREMOVEDFORSECURITY}}/public_html/magento/vendor/magento/framework/Filesystem/DirectoryList.php(117): Magento\Framework\Filesystem\DirectoryList->normalizePath() #2 /home/{{USERNAMEREMOVEDFORSECURITY}}/public_html/magento/vendor/magento/framework/App/Filesystem/DirectoryList.php(193): Magento\Framework\Filesystem\DirectoryList->__construct() #3 /home/{{USERNAMEREMOVEDFORSECURITY}}/public_html/magento/vendor/magento/framework/App/Bootstrap.php(172): Magento\Framework\App\Filesystem\DirectoryList->__construct() #4 /home/{{USERNAMEREMOVEDFORSECURITY}}/public_html/magento/vendor/magento/framework/App/Bootstrap.php(139): Magento\Framework\App\Bootstrap::createFilesystemDirectoryList() #5 /home/{{USERNAMEREMOVEDFORSECURITY}}/public_html/magento/app/bootstrap.php(46): Magento\Framework\App\Bootstrap::populateAutoloader() #6 /home/{{USERNAMEREMOVEDFORSECURITY}}/public_html/magento/bin/magento(14): require('/home/{{USERNAMEREMOVEDFORSECURITY}}/...') #7 {main} thrown in /home/{{USERNAMEREMOVEDFORSECURITY}}/public_html/magento/vendor/magento/framework/Filesystem/DirectoryList.php on line 137
Install command attempted:
bin/magento setup:install \ --base-url={{BASEURLOFSITE}} \ --db-host=localhost \ --db-name={{DB_NAME}} \ --db-user={{DB_USER}} \ --db-password={{DB_PWD}} \ --admin-firstname={{Me}} \ --admin-lastname={{still me}} \ --admin-email={{My Email}} \ --admin-user={{My Chosen Name}} \ --admin-password={{My Password}} \ --language=en_AU \ --currency=AUD \ --timezone=Australia/Perth \ --use-rewrites=1
The server i'm using matches the requirements as advised by my webhost - I will be using Amazon OpenSearch
Hello @kris0089gmd848,
Check your php version and compatibility with Magento version on both CLI and web user.
Check files folder permissions, it should be like below:
cd <your Magento install dir> // 644 permission for files find . -type f -exec chmod 644 {} \; // 755 permission for directory find . -type d -exec chmod 755 {} \; chmod 644 ./app/etc/*.xml chown -R :<web server group> . chmod u+x bin/magento
I hope it helps!
Its Really Not Able To Install - Prestige Pallava Gardens
Hello @kris0089gmd848,
The error you're encountering, PHP Fatal error: Uncaught TypeError: str_replace(): Argument #3 ($subject) must be of type array|string, bool given, indicates that Magento's DirectoryList.php is receiving a bool value (probably false) instead of the expected string or array. This issue commonly arises when Magento cannot find or access certain paths or configuration values during initialization.
Ensure the pub, var, and generated directories have the correct permissions. Magento needs read and write access to these directories. Set the appropriate permissions:
find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \;
ensure the web server user (e.g., www-data, apache) has ownership:
sudo chown -R www-data:www-data /path/to/magento/directory
Check if the app/etc/env.php file exists. If the file is incomplete or has incorrect values (especially for paths), Magento might fail to initialize. If this file is missing, Magento might assume certain values as false, leading to the error.
Ensure this file contains the correct configuration, such as:
Ensure you are using a compatible PHP version (for Magento 2.4.5, PHP 7.4 to 8.1 are supported). Also, verify that all required PHP extensions are installed and enabled:
This is the list of required extensions:
You can check installed PHP extensions by running:
php –m
also, clear the magento cache with:
rm -rf var/cache/* rm -rf var/page_cache/*
If the issue will be resolved, Click Kudos & Accept as a Solution.