-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to define WP_DEBUG and other constants in the wp-config.php #17
Comments
Let’s minimize the amount of new ideas wp-cli introduces. We could just use a wp-config.php found in a plugin directory and the developer could add it to .gitignore |
We can let this soak. I'm not sure magically loading a |
It could be loaded as an actual wp-config.php file. The alternative is to introduce a new concept, like a cli switch or an autoloaded blueprint. Then we do it again when the next challenge shows, and before we know it we have a huge config file that requires studying documentation. |
Can we do something like wp-env does and let the user define additional constants in the configuration file? We added support for configuration file in WordPress/wordpress-playground#263 and we already have a mechanism that defines constants in prepended PHP file. |
If you're set on CLI switches and configs then let's use the native Blueprint JSON format for. Blueprints are the main mechanism of customizing Playground. That would involve:
Then you get merging and composing the two for free. Also, The alternative is to hack something for now and end up building a competing blueprint format in |
The blueprint step defineWpConfigConsts takes care of that: defineWpConfigConsts(php, {
“consts”: {
"WP_DEBUG": true
}
}) It can also be used via the JSON API. |
As a workaround, I modify the We recently updated Playground to support |
Playground now supports setting The following Blueprint: {
"constants": {
"WP_DEBUG": false,
"WP_DEBUG_LOG": true,
"SAVEQUERIES": true,
"NEW_CONSTANT": "new constant"
}
} Will rewrite the following <?php
define('WP_DEBUG', true);
// The third define() argument is also supported:
define('SAVEQUERIES', false, true);
// Expression are wrapped in `if(!defined())` guards
define(true ? 'WP_DEBUG_LOG' : 'WP_DEBUG_LOG', 123);
// Guarded expressions shouldn't be wrapped twice
if(!defined(1 ? 'A' : 'B')) {
define(1 ? 'A' : 'B', 0);
}
// More advanced expression
define((function() use($x) {
return [$x, 'a'];
})(), 123); As follows: <?php
define('WP_DEBUG_LOG',true);
define('NEW_CONSTANT','new constant');
?><?php
define('WP_DEBUG',false);
// The third define() argument is also supported:
define('SAVEQUERIES',true, true);
// Expression are wrapped in `if(!defined())` guards
if(!defined($const ? 'WP_DEBUG_LOG' : 'WP_DEBUG_LOG')) {
define($const ? 'WP_DEBUG_LOG' : 'WP_DEBUG_LOG', 123);
}
// Guarded expressions shouldn't be wrapped twice
if(!defined(1 ? 'A' : 'B')) {
define(1 ? 'A' : 'B', 0);
}
// More advanced expression
if(!defined((function() use($x) {
return [$x, 'a'];
})())) {
define((function() use($x) {
return [$x, 'a'];
})(), 123);
} It is still possible to define the constants in PHP runtime instead of rewriting the file by explicitly using the This, I believe, concludes this issue. |
Some developers would like to change the behavior of their
wp-now
sites withdefine( 'WP_DEBUG', true );
. Other developers may want to define other constants early.Related #19, WordPress/wordpress-playground#230
Done is:
wp-config.php
.The text was updated successfully, but these errors were encountered: