Tag Archives: php

CodeIgniter Starter project

Update: As requested, here’s a demo site.

In preparation for a new CodeIgniter project starting very soon, I prepared a new project template. While CI gives you a great library and framework, out of the “box” it is missing a few things that are necessary for 90% of web applications. Specifically, user registration and authentication, menus, templates, a CSS base, etc. Other frameworks, such as Yii or Django, address this with generators. I think there is some value in creating one’s own. A fine alternative would be to go with another CI-based project framework, especially FUEL CMS, or perhaps PyroCMS.

I am very intrigued by the Sparks initiative also; I think it’s a great idea and a good way to let developers like me pick and choose open libraries, as well as give back. So my first shot at this involves setting up Sparks, integrating a few useful ones, and making a basic site with templates, navigation, registration and login. Everything else will be project-specific, I imagine.

In any event, here’s what I included in my first version:

PyroCMS Modules

At White Lion, we had use of an in-house framework built on Kohana that made starting a new site very easy. Since I’m back on my own I can’t use their framework for my own projects but I see the value of using a full-blown CMS system as a starter, not just a framework. There are a few CodeIgniter-based CMS projects with some traction, but PyroCMS and Fuel CMS both grabbed my attention. PyroCMS won out because it’s reached 1.2 and module development is very simple, and I’m a fan of Phil Sturgeon.

I have so far tried my hand at developing two modules for PyroCMS: one is a sitemap module which outputs both a human readable and search engine friendly XML sitemap of all pages and blog posts, and the second is a blog importer, mainly for moving my content on this blog from WordPress to PyroCMS. I dutifully submitted both to the add-on store, but both haven’t been accepted after a week or so of sitting around “waiting for approval”. So, temporarily, I will offer both downloads here as a trial: (these are now live on the add-on section, links have been updated)

If you’re a PyroCMS user or developer, please check them out and let me know what you think on the forum. As for future plugins, I’m thinking of doing a Lucerne search plugin, or a simple Google Checkout/Cart module, or maybe a call-me widget based on Twilio’s API.

I am a freelance web developer, and if you want to hire me to build something for your website, please get in touch.

Recording Web Audio

Update 6/1/11: WebRTC looks very promising.

Update 11/05/09: Looks like this might be possible in Flash 10.1! (via)

I’ve been working on a project recently that would really benefit from the ability to record audio in the browser and upload it to a web server. This would be a better experience than an “upload your sound file” dialog, where the user would have to record themselves in another app, find the file, and upload it. Here’s how I imagine a seamless audio capture experience would work inside a web application. There would be a small widget in the page that would look like this (icons from FamFamFam.com):

Recorder state 1 When the widget first shows, only the record button would be enabled. The left side has a line-level indicator that reflects the sound level at all times.

Recorder state 2 While recording, the recording button changes to a stop button.

Recorder state 3 Once the recording is stopped, the stop button changes back to a record button. The play and upload buttons are enabled. Clicking upload at this point saves the file to the server, and the whole control would change to an upload progress bar. Clicking record here starts a new recording and erases the old one.

Recorder state 4 During playback, the record button toggles to a stop button again and the play button toggles to a pause button. The line level reflects the playback volume. It is possible that you don’t want to allow upload during playback, but I’m not sure.

I want the control to be slightly customizable for the web developer who’s embedding it. He/she should be able to specify a maximum recording length and a URL where the sound file will be uploaded, or perhaps disable playback and upload immediately, that sort of thing. Maybe the control itself is actually a 1×1 SWF that has methods and events for play, stop, record, and so on, and the controls would be standard HTML wired up with JavaScript.

I assumed that other, smarter people have already tackled this problem and there is some Flash control I could embed in my page and a little PHP script or something to handle saving the file from a POST. If you’ve ever searched for this sort of thing before, you already know that it does not yet exist, at least not like I have described it.  Microsoft Silverlight doesn’t yet have microphone access, and I can’t find a Java applet that does this thing either. (I found this one, hmmm. Wish it was free/Flash). There are several very nice Flash playback scripts (SoundManager 2, Yahoo Media Player, JW FLV Media Player, JPlayer, NiftyPlayer, WordPress Audio Player, etc. etc. etc.), but nothing that handles creating uploading and saving recordings. Yet.

Flash allows for audio streaming from the client microphone, but in order to capture the stream you need a server that understands Adobe’s streaming format called RTMP and can do something with it, most likely some kind of crazy-expensive Flash Media Server or the open source Red 5 server. Neither solution is exactly straightforward or doable on a simple web host; it’s huge overkill for this one thing. If your project is meant to be downloaded and run on other servers (like WordPress and my new project) this kind of requirement is deal breaker. Besides, it doesn’t really allow you to preview the recording before it’s uploaded. Frustration with Adobe’s “closed” microphone interface has caused some Flash developers to start the Open Mic initiative at GetMicrophone.com. I wish them luck with their effort.

I recently asked my friend Joey Betz (a very talented Flash programmer who works for Armor Games) if what I describe above is possible. He said that up until Flash 9 it is impossible, but he could imagine that with new access to microphone sound data in Flash 10, it may be possible to get the byte stream of the sound and base-64 encode and post it to a web script. I guess nobody has the combined need, interest and Flash/PHP chops to make it happen – I have all but the Flash bit. I’m not sure anyone knows the actual format of the byte stream: is it just raw sound like a WAV or what? Can you turn around and replay that byte stream through Flash? How do you turn it into an MP3/OGG stream? Even if the byte stream is something odd or uncompressed, perhaps the PHP script could do the heavy lifting to re-encode it; many servers also have FFMPEG or Mencode or something like them installed. Alternatively, what about a web service with an API where I can stream data to a Flash Media Server or something like it and get back a URL to the resulting MP3? I just don’t think recording a few seconds of sound and saving it to a file requires a separate server daemon and all that entails. Real-time voice/video chat — sure, but that’s not what I’m after.

Unless someone can convince me that this is still not possible, I will be happy to offer some of my time and server bandwidth, hosted now at MediaTemple, to help a creative Flash programmer get the server-side bit of this working. I’d like to release this widget/script as open source to the web community. I am looking especially to the creators of any of the aforementioned Flash playback scripts. Can you help make this happen?

How ThisLineIsSecure.com was built

Here is a quick rundown of how my recently launched site ThisLineIsSecure.com was built. First of all, it would not have been possible without the Twilio API. Besides that:

I need to tally up my expenses, but besides my time I’m probably out less than $200 for this whole thing so far. Unbelievable. I think that the Kohana project, Nuvio, the WordPress Audio Player, and Cyberduck each deserve at least a $20 donation, which will be forthcoming.