Programming

Working with Silex

Update: Gregorie Pineau pointed out to me that this was already done, so I will refer you to the more canonical resources: Silex Skeleton and Silex Kitchen Edition.

Update #2: However it does seem that my setup may be even more minimal than even Fabian’s Skeleton, which could be a benefit to some.

One of the inherent problems of micro frameworks is the tendency to just go … willy nilly … and put your files in any ol’ spot. It makes the code look awful and hurts your brain trying to comprehend where to handle your changes, and then your project turns against you.

To that end, I want to help! Who’s surprised? Awww, c’mon! Pretend? Ok. Thanks.

I have created a Sample Silex Install on GitHub that shows some of the best practices for working w/ composer, and getting off to a great start with your next Silex project.

Questions? Comments? Please leave them below!

How I came to terms with the Symfony CMF project

Let’s get this out there up front, writing and maintaining CMSs is my bread and butter. I maintain a large one for my day job, and use a small one for client sites after-hours. I think about them a lot. I try to think of how to make the ones I build better, and most importantly to me, how to improve the user experience.

Let me also point out that my writing style can be a little rambling, but I promise I will get to the point eventually.

So when I initially heard about Lukas Smith‘s Symfony CMS project, I got very very interested.

I read the slides, looked at the demo, and then looked at the demo’s admin dashboard.

Holy crap.

Look at the dashboard. Seriously, go look at it now if you haven’t yet. What is all of that, and how could I ever get a client to understand any of it? There’s no way my clients would accept anything like this. And that’s where my brain got stuck. That’s where I started to doubt Lukas’s sanity.

And I stayed that way for quite a while. Maybe a month, maybe two, maybe more. I’m not entirely sure.

Then one night, some of us in #symfony (IRC on freenode, participants were Edler, cordoval, and nveid, as I recall) were doing a show-and-tell of our various CMS platforms. Some were CMF backed, some were not.  Somewhere in the mix, it all started to make sense, but we have to look at this one piece at a time.

This goes beyond an API and interface for managing content

At the very core of the CMF project, it is about storage, or rather, using the appropriate form of storage. It’s about using the right tool for the job. It’s about no longer using your shoe to hammer in a nail.

We all put our content in a database, and those databases all offer a various set of low-level tools to help us insert, update, and delete content. As I have been able to understand, the CMF project is about bringing content management to a new ‘minimum standard’. Symfony in general tries to bring best practices from all walks of life into the PHP developer’s toolkit. CMF is doing that for content systems. Those crazy Java guys? They already solved this whole content storage issue.

From the linked Wikipedia article:

A JCR is a type of object database tailored to storing, searching, and retrieving hierarchical data. The JCR API grew out of the needs of content management systems, which require storing documents and other binary objects with associated metadata; however, the API is applicable to many additional types of application. In addition to object storage, the JCR provides: APIs for versioning of data; transactions; observation of changes in data; and import or export of data to XML in a standard way.

HOLY CRAP!

Look at all of that stuff that a JCR based content repository gives us out of the box? No wonder Lukas is pushing this. It’s right in line with the Symfony mentality of giving us a better base line situation. Re-read that quote again. Searching. Storing/retrieving hierarchal data (think folders, directories, paths, children, leafs, whatever term suits you), versions, data migration.

So we have a new way to store our data. What are the downsides? Well, currently I think the only full implementation of a JCR is Apache Jackrabbit. The CMF team is working on Jackalope (which is working, but still missing several JCR features), and there is also Midgard2 (which I am unsure of it’s current level of support for the JCR spec), among others.

About that demo

What finally clicked, I think, is that the CMF demo isn’t to show us what our client’s delivered site would look or work like. The CMF demo is to show us the tip of the iceberg of what is possible with the new framework. It’s part tech demo and part inspection tool. That’s why there’s all of that confusing stuff there. It’s 50 ways of looking at the same data set. The repository. The content repository. Because the content repository is new, and we will want to poke around at it, and see what happens when we do various things to it. It’s the proving ground, not the polish.

Now I am excited.

twitter