flyntwp / flynt-starter-theme

The starter theme for building Flynt projects.
MIT License
69 stars 4 forks source link

Use of undefined constant WP_ENV #299

Open timostsauber opened 5 years ago

timostsauber commented 5 years ago

Warning: Use of undefined constant WP_ENV - assumed 'WP_ENV' (this will throw an Error in a future version of PHP) in /app/public/wp-content/themes/flynt-starter-theme/dist/Features/ComponentLogServer/functions.php on line 30 Warning: Use of undefined constant WP_ENV - assumed 'WP_ENV' (this will throw an Error in a future version of PHP) in /app/public/wp-content/themes/flynt-starter-theme/dist/Features/ComponentLogServer/functions.php on line 30 Warning: Use of undefined constant WP_ENV - assumed 'WP_ENV' (this will throw an Error in a future version of PHP) in /app/public/wp-content/themes/flynt-starter-theme/dist/Features/ComponentLogServer/functions.php on line 30 Warning: Use of undefined constant WP_ENV - assumed 'WP_ENV' (this will throw an Error in a future version of PHP) in /app/public/wp-content/themes/flynt-starter-theme/dist/Features/ComponentLogServer/functions.php on line 30

Obviously this message goes away if I define WP_ENV in wp-config.php e.g. define('WP_ENV', 'development');

But I'm wondering:

Loving the theme so far, awesome work Bleech_ : )

PHP 7.2.9 | using Local by Flywheel | WP_DEBUG = true

bdbch commented 5 years ago

@timostsauber are you using the theme only or did you use the flynt-cli tool to setup the boilerplate + theme? The boilerplate uses bedrock as far as I know which handles environment variables in env files. Bedrock defines the WP_ENV constant in config/application.php FYI.

If the wordpress setup is created manually I think the wp-config.php is the "correct" (imho ideal) place for important WP constant definitions in my opinion because it's loaded before your WP theme and plugins as far as I understood.


Because of your second question: I didn't used the feature, I think it's new, my last project was created a few months ago so I'm probably missing it.

It's used here: https://github.com/flyntwp/flynt-starter-theme/blob/master/Features/ComponentLogServer/functions.php#L30

So the WP_ENV variable is used to make sure this log function is not available in production mode. I'm not sure how to make this easy to use with and without the WP_ENV var without having security or potential performance issues on production systems.

Maybe it's just good practice to define a WP_ENV constant and have it documented for non-flynt-cli projects (if it's not documented yet already).


Maybe the Bleech team has more insight! Have a nice day!

timostsauber commented 5 years ago

@bdbch thank you for the quick reply!

That makes sense. I was using the theme only, not the flynt-cli tool this time. I will simply declare the WP_ENV constant in the wp-config.php file, as thats the simplest solution, and seems to work perfectly.

The reason I'm just running the theme only is that I wasn't able to get the flynt-cli tool to work with Local by Flywheel app. I use Flywheel for a lot of our sites, and it has a prescriptive way of generating boilerplate WordPress sites (its own folder structure etc), and I haven't figured out a way to run the Flynt-cli tool in unison with it. I don't suppose you, or the Bleech team, have run across this before?

bdbch commented 5 years ago

@timostsauber great! have fun working with flynt! :) Really changed how I build WP websites.

Never heard of Flywheel yet, but I'm going to check it out and see if I can get it to work with the flynt-cli. Seems like a nice tool for easy dev project management!

timostsauber commented 5 years ago

Thanks @bdbch ! I think I'm going to have a blast working with flynt. I've been playing with it for a few days now, and it looks like it will dramatically change my WP workflow, for the better :)

I will keep investigating the Flywheel + flynt-cli workflow over the coming weeks, after I've mastered the Flynt WP theme first on its own. I believe since the flynt-cli is using Roots Bedrock it may be more of a Bedrock + Local issue, e.g. I just read this -> https://github.com/artifex404/local-bedrock

Local by Flywheel is a fairly decent tool for certain situations, and in the right environment it can save a bunch of time. Their hosting is quite snappy also!