Closed MathieuMenegain closed 4 years ago
Which versions of PHP, WordPress, wordplate/framework
and fiskhandlarn/blade
are you using?
PHP 7.3.2 Wordpress 5.4 composer.json :
{
"name": "wordplate/wordplate",
"description": "A modern WordPress stack built with Composer",
"keywords": [
"wordplate",
"wordpress",
"boilerplate",
"plate"
],
"license": "MIT",
"require": {
"php": "^7.2",
"fiskhandlarn/blade": "^0.4.2",
"johnbillion/extended-cpts": "^4.3",
"koodimonni-language/core-fr_fr": "*",
"matthiasmullie/minify": "^1.3",
"spatie/image-optimizer": "^1.2",
"wordplate/acf": "^8.2",
"wordplate/framework": "^8.1",
"wpackagist-plugin/adminimize": "^1.11",
"wpackagist-plugin/advanced-custom-fields-pro": "^5.8.0",
"wpackagist-plugin/classic-editor": "^1.5",
"wpackagist-plugin/contact-form-7": "^5.1",
"wpackagist-plugin/tinymce-advanced": "^5.4",
"wpackagist-plugin/wordpress-seo": "^13.4",
"wpackagist-plugin/wp-analytify": "^3.0",
"wpackagist-plugin/wp-super-cache": "^1.7"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"installer-paths": {
"public/mu-plugins/{$name}": [
"type:wordpress-muplugin"
],
"public/plugins/{$name}": [
"type:wordpress-plugin"
],
"public/themes/{$name}": [
"type:wordpress-theme"
]
},
"wordpress-install-dir": "public/wordpress",
"dropin-paths": {
"public/languages/": [
"vendor:koodimonni-language"
]
}
},
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org",
"only": [
"wpackagist-plugin/*",
"wpackagist-theme/*"
]
},
{
"type": "composer",
"url": "https://wp-languages.github.io"
},
{
"type": "package",
"package": {
"name": "wpackagist-plugin/advanced-custom-fields-pro",
"type": "wordpress-plugin",
"version": "5.8.0",
"dist": {
"url": "https://connect.advancedcustomfields.com/index.php?v=5.8.0&p=pro&a=download&k=api-key",
"type": "zip"
}
}
}
],
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
]
}
}
}
Hmm, any idea @fiskhandlarn?
To reproduce the problem you can install a new wordplate project and you composer require fiskhandlarn/blade
Just tried it locally and the issue is that wordplate/framework
and illuminate/support
both has the env
function. Which probably means that anyone using illuminate/support
in their project has been using Laravel's env
function instead of the one shipped in WordPlate.
I'm not sure there is anything we can do on our end. What you can do though is to require the vlucas/phpdotenv
package in your composer.json
file. Be sure to install version 3.0.
Late to the party here, sorry about that. The problem is indeed that fiskhandlarn/blade
requires illuminate/view
which requires illuminate/support
. Both illuminate/support
and wordplate/framework
has an env
function in their helpers.php
. But composer chooses to load illuminate/support
before wordplate/framework
(due to alphabetical order perhaps?), thus defining illuminate/support
's env()
. Requiring vlucas/phpdotenv
will not solve this. But I'm working on a fix, bbl!
Which probably means that anyone using
illuminate/support
in their project has been using Laravel'senv
function instead of the one shipped in WordPlate.
Just to be clear: fiskhandlarn/blade
isn't using env()
. This would happen when requiring any package that uses illuminate/support
somewhere down the line.
Sadly, I can't find any solution. Laravel defines a lot of helpers in the global scope and doesn't seem to change that anytime soon: https://github.com/laravel/ideas/issues/1791 https://github.com/laravel/ideas/issues/1609 https://github.com/laravel/ideas/issues/1600 :(
@vinkla Any chance of scoping WordPlate's env()
in a namespace instead of defining it globally? X)
@vinkla Any chance of scoping WordPlate's env() in a namespace instead of defining it globally? X)
I like the idea but it would be a breaking change (require a major version) and many probably would have to update their code bases.
Requiring
vlucas/phpdotenv
will not solve this.
This would solve the missing dependency and remove the error message. Though, it would not solve the env
function conflict. It would just mean you're using env
from illuminate/support
instead of from wordplate/framework
.
I like the idea but it would be a breaking change (require a major version) and many probably would have to update their code bases.
Of course, I understand. Maybe fiskhandlarn/blade
should be removed from the docs then? And/or clarify for users that using any package which depends on illuminate/support
together with WordPlate will break?
This would solve the missing dependency and remove the error message. Though, it would not solve the
env
function conflict. It would just mean you're usingenv
fromilluminate/support
instead of fromwordplate/framework
.
Yeah, sorry, I forgot this issue was about errors in composer. I got the same PHP error in the frontend in my WordPlate installation when I upgraded from version 7.
No, wait, sorry! After updating dependencies in my local fiskhandlarn/blade
and requiring vlucas/phpdotenv
version 4 I'm rid of the error message. I'm gonna publish a new version and document how others can circumvent this problem when using both fiskhandlarn/blade
and WordPlate 8.1.
@menegain This should do it:
composer require vlucas/phpdotenv:"^4.0" fiskhandlarn/blade:"^0.5.0"
@fiskhandlarn it's fine for me, thanks.
Hi,
I have this error when
composer update
:Fatal error: Uncaught Error: Class 'Dotenv\Environment\DotenvFactory' not found in C:\laragon\www\starter\vendor\illuminate\support\helpers.php:646 Stack trace: #0 C:\laragon\www\starter\public\wp-config.php(65): env('WP_PREFIX', 'wp_') #1 C:\laragon\www\starter\public\wordpress\wp-load.php(42): require_once('C:\\laragon\\www\\...') #2 C:\laragon\www\starter\public\wordpress\wp-blog-header.php(13): require_once('C:\\laragon\\www\\...') #3 C:\laragon\www\starter\public\index.php(37): require('C:\\laragon\\www\\...') #4 {main} thrown in C:\laragon\www\starter\vendor\illuminate\support\helpers.php on line 646
I use the package blade of @fiskhandlarn to implement blade to my theme but if i remove this of my
composer.json
, my theme work. An idea to resolve this problem ? I try to reinstall vlucas/dotenv but it's not work.Thanks for your help.