cjsaylor
cjsaylor
Chris's Blog
35 posts
Throughts about web development that won't fit on Twitter.
Don't wanna be here? Send us removal request.
cjsaylor 11 years ago
Text
Domain Driven Design in PHP with libdomain
Lately, I've been utilizing domain driven design in newer projects and features. I've found myself writing a lot of boiler-plate code and decided to create a library to cut down on repeat code.
Libdomain can be used to do a lot of grunt work with setting up PHP objects to act as entities, collections, and value objects.
An entity class that utilizes an immutable value object would look something like this with libdomain:
libdomain_example.php
Other domain managers
Some ORMs come with their own form of entity, but not all. In many cases, an application uses multiple data-stores that may not all be supported by the ORM of choice. This is the opportunity to use a unified entity interface to support domain logic.
Unify
Libdomain is designed in such a way that the base abstract classes (Entity, Collection, CollectionEntity, and ValueObject) are not required to be extended to get their benefits. You can implement their interfaces and hook in the traits that cover the interface implementation. This means the entities created by the ORM of choice can be adapted and unify under a common interface.
2 notes View notes
cjsaylor 11 years ago
Text
Upgrading to Apache 2.4 and Configuration Misconceptions
After upgrading my Vagrant environment to use Ubuntu 14.04 LTS, there were some Apache misconfigurations that came to light. Since 14.04 ships with Apache 2.4 (and my previous configurations were for 2.2), there were a couple of directives that changed, but most importantly the default value for the AllowOverride directive had changed to None. This is what pulled me down the rabbit hole where I discovered the misconfigurations.
Access control and the Directory directive
First, a simple change: Order, Allow, and Deny directives have been removed in favor of the Require directive.
Now for the kicker, AllowOverride's default value changed from All to None. This seems like a no-brainer and shouldn't have been a big deal because all of my VirtualHost configurations that used an .htaccess file were all defining AllowOverride all. Once I upgrade to 2.4, all of those VirtualHosts stopped working with .htaccess.
Why?
Turns out, I had been misconfiguring the AllowOverride directive since Apache 2.2 (old). You can't explicitly define the AllowOverride (or Require for that matter) directive in a Directory directive that contains regex, which affected all of my dynamic VirtualHost configurations. After reading the documentation closer for 2.2 this becomes evident.
Moral of the story
Be sure to read the documentation of software you are using carefully. Don't assume something will work in all cases. You can find a list of most of the things to consider when upgrading from Apache 2.2 to 2.4 in this documentation article.
0 notes
cjsaylor 11 years ago
Link
Reduce number of back-and-forths in pull requests by enforcing code quality at the commit level.
This is a post I authored on Zumba's engineering blog about how to use composer to install a git pre-commit hook that will run PHP codesniffer rules before allowing commits.
1 note View note
cjsaylor 11 years ago
Link
After getting invited to Github's new editor called Atom, I decided to try my hand at writing a custom package. I chose to implement an IRC client to test the view system as well as the node backend.
So far, I'm very impressed at how easy it was to quickly write a package to do what seems to be an abnormal task in a text editor.
0 notes
cjsaylor 11 years ago
Link
Get notified via email when github pull requests become stale.
A short write-up on a node application I wrote that allows notification via email on Github pull requests that are older than a specified period.
0 notes
cjsaylor 11 years ago
Link
How to adapt callback structures to callback queues using deferred objects (promises).
This is an article Steve Young wrote about javascript promises. In the article, he makes the subject approachable by framing an example using jQuery's deferred library.
For a node.js adaptation, see my article on using async library for concurrent mongodb execution.
0 notes
cjsaylor 12 years ago
Link
A new library put out by my coworker Juan Basso for serializing PHP literals and objects into JSON format.
We were looking for a library that could serialize our cart entity object for storage in MongoDB, but couldn't find one that supported recursively translating an object into JSON and back.
You can read the blog post Juan did to get a full understanding and example code for its use.
0 notes
cjsaylor 12 years ago
Link
With an update to a new virtual box from one of Ubuntu's cloud images to Raring Ringtail, PHP 5.4 has become the default PHP version. With PHP 5.3's lifetime coming to an end, it is recommended to start looking at 5.4 among other reasons (huge performance boost chief amongst them).
I've also made the VM box a bit more flexible. Now the bound hostnames are configurable as well as the box hostname. Certain aspects of the machine itself are now configurable, such as system memory and mount type (NFS or not).
Overall, a much needed update to my personal development environment.
There's no rose without thorns
I did encounter a rather nasty Ruby bug with Opscode's PHP cookbook outlined here. That being said, the issue is easy to fix locally until the pull request is merged in and made available downstream.
0 notes
cjsaylor 12 years ago
Link
Now all function calls are bound with context of the subject object. What does this mean? It means you can now access the subject object of the pin from the special callbacks to check state of that object to determine what you'd like to do with the pin.
For example, when $.fn.scrolltab.pinDisplay is called, the value of this will be the subject object. You would be able to check the state of that subject and possibly not display the pin based on your business logic.
0 notes
cjsaylor 12 years ago
Link
You can now add the GChart CakePHP plugin to your project as a composer dependency.
If you are going to use it with composer, you will also need the "composer/installers" dependencies so you can define where you want this to install (app/Plugins, etc).
0 notes
cjsaylor 12 years ago
Link
passport-username - Username authentication strategy for Passport and Node.js.
While working on a node project that supported Twitter's OAuth as a login mechanism and an "anonymous" login which only required a username, I implemented the passport library to handle twitter, but there wasn't a strategy to handle only a username.
I open sourced my strategy for a username only situation which is an adaptation of the passport-local strategy by Jared Hanson.
0 notes
cjsaylor 12 years ago
Link
Using the async library in Node.js for combining multiple MongoDB aggregation queries into a single list without blocking the event queue.
This is a blog post I wrote covering some asynchronous issues I encountered while developing a javascript programming game for a conference in Boston. It's not a new subject, but this is a common problem with not that many "non-theory" content on the matter.
0 notes
cjsaylor 12 years ago
Link
Using PHP5.4 traits in Mongounit to allow a combination of databases to utilize fixtures within the same test case.
0 notes
cjsaylor 12 years ago
Text
My First Development Talk at PHPNW13
This past weekend, I traveled to Manchester, UK to phpnw13 to deliver a talk on event driven development. This is my first scheduled conference talk, and I was excited to receive so many positive reviews as well as some insightful feedback to incorporate for the next time.
As I was reviewing the feedback, there were a couple of points that really struck home for me:
Treat the slides as background, not the focus
It's very tempting as a speaker to look back at the slides. I found myself doing this probably more than I should. It's good to have great content on the slide, but as one of the delegates noted, let the slides augment what you're saying, not the other way around. You almost have to approach it as if you don't have slides and are delivering a regular speech.
Connect the dots
As a presenter on a subject, you assume the role of an expert on that subject. While the talk is being constructed, there are some details that connect certain ideas that you have to illustrate very well or you may lose the audience. You have to assume the audience is not as well versed as you are. What is thought of as a trivial detail needs to be addressed during the talk for the audience to really connect with the subject matter.
Travel Fun
Being an international traveler to these sorts of events allows for interesting happenstances. In this particular case, I didn't actually arrive, due to flight issues, until an hour and a half before I was scheduled to give my talk. By the time I reached the conference center, I had about 20-30 minutes to setup my laptop and do the talk. So lessons learned: pad the travel time.
Conclusion
Overall, it was a great experience. The PHPNW13 conference organizers were all super friendly and understanding of my situation. I met some really smart developers that gave me inspiration, which hopefully was reciprocated by me.
Presentation
0 notes
cjsaylor 12 years ago
Link
New version of Symbiosis (v1.2)
One of the major things brought up during feedback of Symbiosis is the usage of a static instance to manage all of the event callbacks. This release has solved this issue by introducing the Event Registry which is an instanced dispatcher for events.
0 notes
cjsaylor 12 years ago
Link
I originally wrote this plugin as an experiment in writing jQuery plugins. After a long time of rotting, I decided to give it an upgrade, some polish, and finally publish it to the jQuery plugin registry.
0 notes
cjsaylor 12 years ago
Link
Finally got around to redesigning the UI of Boxmeup. I used Twitter's bootstrap as a framework which really made it much simpler to do, just a lot of markup updates.
Next step will be to implement an oauth api to drastically simplify the api auth request signing.
0 notes