

Epiphany, a RESTful micro PHP framework I wrote/use for my startups - jmathai
https://github.com/jmathai/epiphany

======
jmathai
I wrote this framework 4 years ago and have been using and iterating it since.
In an effort to polish it off I decided to document it and ask others to use
it as well.

I'm not a fan of large frameworks that do all sorts of voodoo on my behalf.
This framework is less than 1300 lines of code and includes

    
    
       * a RESTful routing module that supports regular expressions
       * a templating module
       * a session module that supports native, APC and Memcached
       * a caching module that supports APC and Memcached
       * a config module that supports overloading of multiple config files
       * a database module that supports PDO MySql and prepared statements
    

I've used it on publicitweet.com (sold), textbookrevolt.com and
thescholarapp.com. It's got some good usage but I'd like to iron out bugs I
haven't come across and let others use it if they'd like.

~~~
jacquesm
That was a lot of work!

I went down much the same route (though by the looks of it you've done a
better job) and recently have decided to scrap the whole thing in favor of
Yii, which I really hope is a good long term decision (always dicey).

What are your long term plans, is this a fire-and-forget thing or are you
going to continue to maintain it and accept patches and so on ?

Is there a roadmap where you want to go with this ?

~~~
AlexMuir
You won't regret going the Yii route. I'm amazed that people are still coding
the basics from the ground up when there are already top-notch frameworks out
there.

~~~
petervandijck
Yii's approach of "create db first, then we create heaps of code for you"
doesn't appeal to me at all...

~~~
AlexMuir
Out of curiousity (and not snarky at all), what other approaches are there in
the PHP world?

~~~
jmathai
I guess I've never been interested in a framework building out classes based
on my database tables so I'm not sure what the alternative approaches are. Is
that what you meant?

If you prefer than then I do think the larger frameworks are a good fit. What
I'm saying is that I don't prefer that :).

~~~
AlexMuir
I've got you, but I'm wondering what your approach is? I'm stuck in a mindset
where I work from creating a database to CRUD to functional code.

~~~
jmathai
I write the CRUD statements but only as I need them. For a lot of my tables I
never intend on deleting records so a delete method never gets written.

If I need to do a SELECT on a specific field(s) then I write that statement.
It's usually a 4 line function in a class that deals primarily with that table
(but not necessarily as it may make sense in a different class).

I use static functions for that as well.

    
    
       class User {
          public static function getByEmail($email) {
             return getDatabase()->one('SELECT * FROM user WHERE email=:email',
               array(':email' => $email));
          }
       }
    

I don't typically end up with so many of those that it's unmanageable and
writing it takes about 30 seconds.

That's my approach. What's your thought on that coming from the mindset that a
lot of that is taken care of by the framework? I'm curious since that's not a
mindset I've had yet.

------
wccrawford
On man's voodoo is another man's bread and butter.

Not to downplay your work, but pretty much all frameworks are written to
reduce future work and standardize things. Just like you've done.

I've definitely had that 'too much magic' feeling with frameworks, but that
goes away as I learn more about how they work.

~~~
jmathai
It may just be my style of coding or thinking but I can't imagine being more
productive with larger frameworks (we use symfony at work).

I just want the bare essentials taken care of and I have a well established
coding style that hasn't been dictated by any framework - for some reason I
like that :).

This is definitely not meant to lure people away from larger frameworks but
for someone like me who wants something that does less on my behalf.

------
trey
I've been using nicedog for my micro-framework needs.

After looking over it, this is a really framework. There really isn't too much
that I would throw out to make it smaller, except maybe the curl wrapping
class.

A couple of things that would be nice are:

1) if your Controller classes had some state forcing them to be static like
you do means that there could be a lot of duplicated code between similar
actions

2) if you had a 'layout' template that could be set that would wrap the
results of the actions. Maybe this already exists, I just couldn't find it.

Its very clear that you intend to not do any kinds of magic, so I can see why
you left a lot of things out that a lot of other frameworks have. Maybe that
is why you don't have a layout wrapper template.

~~~
jmathai
You're right about the curl wrapper. It's actually got it's own repository
<https://github.com/jmathai/php-multi-curl> so I should remove it from here
(it's an artifact really).

1) I'm not sure exactly what you mean. I handle most of the code duplication
in libraries so my static controller methods are usually really small (<15
lines). Let me know if I misunderstood your point.

2) You're right about the layout wrapper being a bit "heavy" for this
framework. You can nest layouts to your heart's desire but the views are 100%
decoupled from the actions. You can, in fact, use the the template module
without using the route module. Not that you'd want to :).

------
petervandijck
I'm getting this error in my apache logs after installing it locally, although
I have mod_rewrite turned on:

[error] [client 127.0.0.1] File does not exist: C:/Users/Peter/Documents/My
Websites/epiphany/database, referer: <http://epiphany.peter/examples/>

Seems to be some mod_rewrite problem?

(ps: the main page at <http://epiphany.peter/examples/> loads fine)

Suggestions anyone?

~~~
jmathai
Feel free to open an issue in Github and I'll help get things sorted. I can't
reach ephiphany.peter since that looks like a locally resolvable hostname.

First item to check is to make sure you have a .htaccess in all your examples
subdirectories. It should be part of the repository.

~~~
petervandijck
Thanks. It seems to be looking for the "/database" file, instead of for the
"/database/index.php" file, which makes me think it's a rewrite problem...

~~~
petervandijck
Here goes: <https://github.com/jmathai/epiphany/issues/issue/28>

------
petervandijck
Wondering, are there bits you've been wanting to add to it? And similarly,
what are the bits that you like most?

~~~
jmathai
At the moment I've added what I need so far. But the point of documenting it
is so others can use it and provide input on what's missing.

The next task in my mind is to have good unit test coverage.

~~~
petervandijck
Documentation is really nice by the way. I also like the simplicity a lot. It
feels like there's little to learn after reading through the docs quickly.
Good stuff. (ps: for me personally, I don't use unit tests (yea I know,
horrid), so not really needed).

~~~
jmathai
Glad the docs were easy to follow. The main purpose I see for unit tests is to
make sure that future changes don't change/break existing functionality.

They're a lot of work to write/maintain so I only write them when the added
value exceeds the cost :).

