A URL shortener in a couple of hours

I have been aware of Silex for a while as a nice microframework based on Symfony2, and have looked into it a couple of times to see if it would be useful for a project. So far though, the projects I was working on seemed to need more than just Silex, so I picked Symfony2 instead. This morning, I decided to dig into Silex a bit more with a real-world project I still wanted to develop myself: A URL shortener.

About Silex

Silex is one of the many microframeworks we've seen pop up recently. Contrary to most other microframeworks, however, Silex is built on top of an existing open source project: Symfony2. A microframework is a very small framework which basically does nothing more than bootstrap and handle your request and response. Though the microframeworks cater to a very specific need, I really like the approach of not needing a full framework for a project that clearly is simple enough not to need one.

Some things I really like about Silex are:

  • Built on top of existing open source components
  • Packaged in a phar package
  • Extensible: There are extensions available to the Silex core, and I can extend it even more

Sitting down

This morning, I sat down to have a look at Silex and see how it works. I simply downloaded the phar, set up my basic project, and started working on setting up what I had in mind. Every time I got stuck or needed some info, I just Googled the topic to find the answer.

And this is where the first "problem" arose. I followed the steps in one of the pages I found on the official Silex and ran into an error telling me Silex\Extension\TwigExtension could not be loaded. Thanks to @Stof70, however, I found out that actually, I was looking at an old version of the documentation, and Extensions had been renamed to ServiceProviders. After changing my code, everything was working again!

Using this approach, it only took me a couple of hours to get a working version of my URL shortener. I did this by a constant refactoring, starting off with a very simple version and then constantly improving this code up to a point where I had what I wanted. Quite nice. Now it's time for some real-life testing :)

When Silex

What I've found is that Silex (or any other microframework for that matter) is an excellent approach for small projects where you start with an idea of what you want to build and then improve on your existing code. It is very tempting to put in hackish solutions, which is OK if you keep on improving your code but you have to actually do that and not keep the hackish solution.

Another great situation where you might want to use a microframework is for quick prototyping, if you want to build a quick prototype for a customer to show them what can be done, and have the opportunity of rebuilding it later for the final version, a microframework will give you everything you need for the basic setup. Quite nice! So try it! Just take a couple of hours and an idea of a simple site or app you want to build, and start building. Even if you never use it later on, you'll have learned something new, which is always good.


Add comment

Comments

gravatar glutathione iv injection: powered by potent antioxidant glutathione as well as vitamin c, magnesium, and b vitamins, this iv takes only 15-30 minutes and can energize after a long and stressful week or as part of a longevity protocol. when you find the best facial cream for you, be sure to use it consistently. when they come together, they usually create either a boy or a girl; two x’s makes a girl, and an x and a y creates a boy.
February 28, 2013
gravatar voice recorder with usb port: to find and download the philips sound drivers please choose the appropriate philips voice tracer digital recorder lfh0662 2 5 things to do with school or church youth groups navigate: humor --> executive toys and desktop devices --> digital voice pen recorder. olympus professional dictation systems are designed to dramatically increase efficiency and streamline operations.
March 4, 2013
gravatar microscope hans janssen: the functional requirements of the system will dictate the hardware and software specifications, for example the read / write capabilities of the rfid tags will ultimately be dictated by the business objectives. use this printable as a handout or transparency to help prepare students for working . i like to have students complete this activity after they complete their microscope quiz. isolation is provided by the same gimbal piston element that provides unsurpassed performance in isolating optical tables, electron microscopes, precision balances, and 20 series tables. these are not high use items, nor are they used to tighten to extremes.
May 16, 2013
gravatar voice recorder wifi: digital voice recorder with 4gb memory, noise reduction & intelligent file management. quick overview: tiny, featured packed digital recorder with unique "no battery drain" mode when connected to a single line telephone. package contents: vn-8100pc 2gb digital voice recorder.
May 22, 2013
gravatar Cheap Phentermine 3.75 Mg Out: does phen375 work? most of the best fat loss pills contain some of the ingredients that are included in this pill, but they dont contain all nine of them. this combination of effective fat loss ingredients helps people to lose weight quickly and easily. while making use of the phen375 pills you can expect to loss close to five pounds a week. this is the best natural fat burner pill that can help lose weight in the short term and also over a long period of time. phen375, for instance, contains no phentermine but works in a similar manner by super-boosting the organism's metabolism and fat-burning mechanism, decreasing hunger and cravings for food, and increasing energy. due to the fact its debut on the internet market scene in 2009, phen375 slimmers from the uk, usa, canada and all over the world report substantial fat burning with having zero of the troublesome and typically dangerous side effects of phentermine! this weight loss drug is intended for patients 16 or older (but not younger) who are obese and have another serious condition. the patient would have to fall into the definition of obese based on a standard body mass index (bmi) calculation and have one or more of the following conditions: high cholesterol, diabetes, or high blood pressure, according to drugs.com heart disease is a serious disease that occurs directly in the heart and the blood vessel system that makes the heart operate. the most well-known type of heart disease is coronary artery disease and ischemic heart disease. in fact, heart disease is the number one killer in both women and men. the connection with obesity is because those that are obese normally suffer from common risk factors of heart disease like high blood pressure and high cholesterol.
June 4, 2013
gravatar glutathione supplement autism: there was some concern when first joe passed away, and then may, that leslie would stop his music, but thankfully, he hasn't. otherwise, the existence of growth hormone injected or fed to the animals may interfere with the function of central nervous system in regulating the production of the child's hormones, thus increasing the severity of the symptoms and brain tumors and cancers as we mentioned in previous article. the home hydroponic gardener may not spend much time thinking about pests and diseases.
June 6, 2013

Php5_zce_logo

Tags

1337 2008 2010 2011 4developers access modifiers accessibility AdaLovelaceDay09 advent agavi agile alfred amsterdam amsterdamphp apache api apple article articles atk atkMetaNode audioscrobbler autoloading automation azure backwards compatibility barcelona barcodes bash bbc bbq beatstad belgium best practices bittorrent blogging blogs boards of canada book books bughuntday bundle caching cake cal evans calendar career cat cerf certificate cfp cilex clear cms cologne common sense communities community components composer conference conferences contest continuous integration contribute contribution crisis css curl custom d-day data migration datetime DbFinderPlugin decorator decorators deployment deps devdays development directoryindex directoryiterator docblox doctrine doctrine2 documentation download dpc dpc09 dpc10 dpc11 DPC2008 dreamhost drupal dv7 eclipse ed editors efficiency enterprise errors event events expertise ezcomponents facebook filter-branch filteriterator finland flickr fork framework frameworks free ticket freelance freeze frontend fun game games geoip germany getting real git github globiterator gnome-do google google calendar googletalk graceful degradation hack hackers hidden gem hiphop howto hp HR html http i386 ibuildings icann ide ideasofmarch idm imovie inclusivity indy ingewikkeld integration international php conference internet interview ipad IPC ipc ipc08 ipc10 ipc11se iterators iterm2 javascript jenkins jenkins-php job job openings jobeet john peel joomla joomladays kiva kubuntu launcher launchy left on the web libcurl libraries library lighttpd lime linktuesday linux live london loudblog m2ts mac magazines malware mambo manchester marjolein mediterra meeting meme meta methodology micro-financing microframework microsoft migration movie music mysql namespace namespaces netbeans netherlands newsfire nllgg northeastphp nos odmarco open source opinion ORM osx paradiso paris partnership pavilion pear pecl performance personal pfc10 pfc11 pfcongres pfcongrez pfz pfz.nl photo php PHP php5.3 phpabstract phpazure phpBB phpbb phpbelgium phpbenelux phpbnl10 phpday phpdoc phpdocumentor phpgg phpitalia phpnw phpnw08 phpnw11 phpnw12 phpstorm phptek phptek09 phpuk2009 phpUnderControl phpunit php|architect php|tek podcast politics portability postcrossing presentation presentations private projects protected prototype PSR-0 public python qa qr codes re2c recruiting refactoring review rewrite ruby on rails san francisco schedule scifi script security sensio seven things sexism sfdaycgn sflive2011 shell scripting silex simplexml slides smfony software sogeti solar sound speakers spl ssh standard standards star trek static steer strings stylesheets subversion symfony symfony live symfony2 Symfony2 symfonycamp symfonyday symfonylive symfonyUnderControlPlugin talk talks tech techademy technology techportal tek09 telecommuting terratec terrorism testfest testing textmate textpattern the right tool timeout tips tld todo tomas tools training twig uncon unet usability usergroup validation vhost video vim vinyl virus warp webinar weblogging webservices wiki windows winphp women wordpress work workshop world world of warcraft wpi writing wunderlist xml xpath xsd yara year youtube zc11 ZCE zemanta zend zend framework zend server zend studio zendcon Zend_Form zite
© 2004 - 2013 Stefan Koopmanschap + Powered by Symfony, photos powered by Flickr, links powered by Delicious, Shanghai smilies by Iconbuffet. Feeds: rss / atom. Left on the Web v4.4.0.1