Jump to content

a wrapper for processwire


Recommended Posts

Hi all, i'm new to Processwire and i'm very curious about this minimal cms, i'm also a great lover of php frameworks and currently i'm working with Kohana.

I love the fact that Processwire has a simple and detailed api and the "include & bootstrap" feature is killer (my 2 cents). Anyway, i tried to implement it with Kohana and i found 2 errors.

The first is the double declaration of the __() function (error: "Cannot redeclare __()")

fortunately is possible deactivate the translation system in kohana, but the second one is something i cannot solve without modify the core:

ErrorException [ Fatal Error ]: Cannot instantiate abstract class Session

This makes me think that Processwire uses a class named 'Session', and this name collide with the same Kohana Class. I don't really know how to solve this. Is there a way to create a wrapper for the processwire api or i must just hope that a future versione of Processwire will prefix every core class ? (es: Pw_Session) :(

Link to comment
Share on other sites

Welcome to the forums designofseven!

I'm looking forward to using PHP 5.3 namespaces so that this would not be an issue. However, we've still got a lot of people using PHP 5.2 and not sure we can safely require 5.3 just yet. Perhaps we can test the waters with PW 2.3. For now, I would to a search/replace on whatever system is not in control of the Session. So if it's PW, then you could do a global search/replace of Session with PWSession, or if it's Kohana then you could do a search/replace with KSession.

Link to comment
Share on other sites

Yep, but change the core is something that makes me sad :)

Anyway i've got an idea: Create a file/class with a namespace. within this file include the processwire system api and then include the file in Kohana.

I'm not (yet) good with namespaces but this should do the trick, gonna try it now.

ps: forgive me for my english :)


i must learn namespaces (isn't working)

Link to comment
Share on other sites

@designofseven I definitely agree with you about changing the core. But I think you only have to look at it as a temporary thing until PW 2.3. If you want to give it a try, here's what you have to do:

1. Edit /wire/core/Session.php and change this:

class Session extends Wire implements IteratorAggregate {

to this:

class WireSession extends Wire implements IteratorAggregate {

2. Edit /wire/core/ProcessWire.php and change this:

$session = new Session();

to this:

$session = new WireSession();
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

  • Create New...