Jump to content

Problem with: $config->moduleCompile = false


LimeWub
 Share

Recommended Posts

For debugging reasons, while I'm developing a site, I want the modules not to pre-compile or be stored in the cache.

There is this setting, which can be set in the config:

$config->moduleCompile = false;

This is supposed to stop modules getting pre-compiled and stored in cache. I think so at least. (if I'm using the wrong setting or if there's some other way to ignore cache let me know pls)

 

When I set that to false, my module files get loaded, but because they haven't gone through the file compiler their class declarations look like this:

abstract class TemplateEngine extends Wire

instead of this:

abstract class TemplateEngine extends ProcessWire\Wire

and thus the error I get is this:

Error: Class 'Wire' not found (line 20 of /Users/me/websitename/www/site/modules/TemplateEngineFactory/TemplateEngine.php)

 

Can someone help me with this issue? Is there some way for me to set the scope of where the modules are looking for, for classes like "Wire" etc, to be processwire's?

Something else I'm doing wrong?

 

Do I just NEED the modules to compile and I should just deal with it?

 

Thanks.

Link to comment
Share on other sites

Welcome @LimeWub,

that is what the module compiler is for. If you are using PW 3.x.x it adds the ProcessWire namespace to the module files to make them compatible with PW3. If you don't want to deal with namespaces there is also PW 2.8.x available. But it is only recommended to use for existing projects. For new projects PW 3.x.x is the way to go.

If you want to disable the module compiler, you would have to add the namespace in the module files by yourself to resolve the issues you mentioned above. But do you want to debug modules or are you trying to debug your template files? If that is the case, you could try to disable the template compiler in your config or in your templates

Regards, Andreas

  • Like 2
Link to comment
Share on other sites

3 hours ago, AndZyk said:

Welcome @LimeWub,

that is what the module compiler is for. If you are using PW 3.x.x it adds the ProcessWire namespace to the module files to make them compatible with PW3. If you don't want to deal with namespaces there is also PW 2.8.x available. But it is only recommended to use for existing projects. For new projects PW 3.x.x is the way to go.

If you want to disable the module compiler, you would have to add the namespace in the module files by yourself to resolve the issues you mentioned above. But do you want to debug modules or are you trying to debug your template files? If that is the case, you could try to disable the template compiler in your config or in your templates

Regards, Andreas

 

Thanks for the response Andreas :)

 

Let me explain why I would prefer the modules (and yup it's defo the modules unfortunately and not the templates) not to be cached/pre-compiled, more specifically:

It's been decided to use smarty templating in our project, but it doesn't quite do what we need.

Thus the plan is to write a plugin for smarty (which is proving much more complicated to extend than I thought).

My life, while writing this plugin, will be made much easier if I can step through the PHP I'm writing (bare in mind, I'm a newbie with both ProcessWire and Smarty so it's extra useful for me to be able to see what the functions I'm using are actually doing).

Sometimes, however, it gets a bit confusing which file I'm using. Editing the plugin in the module's directory but then debugging it from the cache is kind of an awkward step.

Which is why I'd prefer it if it's module at least (that's TemplateEngineSmarty or so) wouldn't be cached. :)

 

Is there not any way to just ask ProcessWire to ignore the cache and just compile every time I run, maybe?

Again any other suggestions in regards to this are welcome.

 

I'd be esp interested to hear from module creators who use IDEs how they deal with this. ^^

 

Link to comment
Share on other sites

Thank you for clarifying. I never developed a module or tried the Smarty for the TemplateEngineFactory module, so I'm not very helpful. ;)

But here are some ways on how to bypass the file compiler. Maybe adding // FileCompiler=0 in your module files will do the trick.

Also there is a core module File Compiler Tags which is maybe similar to Smarty.

As to your question on how to develop modules using an IDE, the latest blog posts could be interesting for you:

https://processwire.com/blog/posts/processwire-3.0.39-core-updates/
https://processwire.com/blog/posts/processwire-3.0.40-core-updates/

  • Like 2
Link to comment
Share on other sites

@LimeWub - if you add the ProcessWire namespace to your module and template files they won't need to be compiled and therefore won't be stored in the assets/cache/FileCompiler folder. All references to wire will work without needing \ProcessWire\wire

But also remember that the version in that folder is updated every time you make a change to the original file anyway, so I guess I don't really understand the problem.

Link to comment
Share on other sites

13 hours ago, adrian said:

@LimeWub - if you add the ProcessWire namespace to your module and template files they won't need to be compiled and therefore won't be stored in the assets/cache/FileCompiler folder. All references to wire will work without needing \ProcessWire\wire

But also remember that the version in that folder is updated every time you make a change to the original file anyway, so I guess I don't really understand the problem.

Is adding the namespace just me adding \ProcessWire\ in front of every extended class in the module? or is there some other way (maybe some config or so)?

The problem is that I have my breakpoints for debugging in one file (compiled and cached), but need to edit a different file(non-compiled). Which causes confusion and lost changes.

Link to comment
Share on other sites

5 hours ago, LimeWub said:

Is adding the namespace just me adding \ProcessWire\ in front of every extended class in the module

No, it's much simpler than that. You just add it once to the top of the file.

<?php namespace ProcessWire;

That's it - now there will be no need for the module to be compiled.

  • Like 2
Link to comment
Share on other sites

8 hours ago, adrian said:

No, it's much simpler than that. You just add it once to the top of the file.


<?php namespace ProcessWire;

That's it - now there will be no need for the module to be compiled.

@LimeWub, one thing to be aware of is that this will make your module incompatible with PW2.x. But that may not be a problem to you.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...