I have mixed feelings about 2012, it wasn't all bad but it certainly wasn't all fun fun fun. Here are some highlights. Very early i was super happy because after a period of three years of laziness  i was finally through university and i was preparing myself to serve mandatory military the coming spring as every other young male in Greece. Unfortunately the following months until May i had a serious health issue which sent me to hospital a couple of times and my precious 4 months of vacations turned into a very stressful period for me.

Anyway May came and my military service started. I have to admit it was better than i thought, living 9 months with no serious worries except what's for dinner and what's my next work duty isn't bad especially if you consider the alternative, which was looking for a job in the worst possible period in Greece going through the worst part of the economical crisis. Unfortunately that came to an end pretty fast as well as i broke my leg. I guess that was my bad since i am not exactly fit. After 2.5 months i was early discharged from military which some people found fortunate, but then again i couldn't walk at all from early    June to late August, so yeah crutches in summer time in Greece, lucky me. Actually i went to the beach many times for rehabilitation, it's not fun trying to walk with crutches on hot sand barefoot. I guess it was if you were watching me! I almost forgot my favorite moment with crutches, my university graduation ceremony which i would have missed if i hadn't broken my leg. Now try to imagine, a nice summer hot morning me with my crutches trying to climb the stairs to get to the stage to receive my degree. I am laughing my ass off right now but trust me i never felt more uncomfortable in my life.

It was about August 15th when i decided to get up from bed and do some actual work. The result, is what you see komposta.net and komposta cmf. On September i started looking for a job as a web developer. I am still looking if you are wondering. I got a little depressed while doing that, because there are not many job offers for all the demand out there and some of them are complete scam. I remember going for an interview for a PHP Developer and they started asking me if i know Ruby. After a while i politely asked them, if you want someone who knows how to code in Ruby why do you ask for a senior PHP Programmer in the job description. The answer was complete BS and the real reason was that they wanted a programmer who could be trained and of course he could be paid much less than a senior programmer. Even though after the interview i politely denied the offer they kept calling me for days to accept the job. :)

Fortunately i took some freelance works and that's what i have been doing for the last 3 months. It's not much but i am not completely broke and i managed to make it until now. I am sure 2013 will be a much better period for job hunting in Greece, so yeah i am little happy i managed to avoid taking up a job i don't really like but then again i am still living with my parents. Even when i was free i tried to stay busy as much as possible with personal projects like komposta and Sum+my.

2012 was tough for many people around the world, i truly believe next year will be much better. Here is my resolutions for 2013

  1. Advance as a php freelance programmer
  2. Get a job i actually like
  3. Do both 1 & 2
  4. Make komposta.net popular
  5. Publish komposta cmf on github
  6. Travel as much as possible
  7. Combine 8 with an F1 race
  8. Run without fear about my broken leg
  9. Do 6 & 7 again
  10. Improve my writting skills in english (thx a lot for reminding me T4Co!)

 I wish you all a very Happy New Year 2013!!

I finished yesterday porting Sum+my to zf2, it will be online after some new features and further development. The process wasn't very hard and you don't have to master zf2 before you begin or even to finish the task. There are already a lot of resources about zf2 and to be able to see code from real life applications from the modules.zendframework.com is a huge bonus. In my case it was a very small application with only 5-6 controllers with a few extra controller plugins, acl + auth + the 15 classes based on Zend\Filter, and it took about 5 hours of work, mostly reading and copy/paste.

First of all performance impressions, out of the box with zero optimization, zf2 is a little friendlier on memory but a little worse on speed. The differences are small but noticeable, i can't give you excact numbers cause i couldn't bother with extensive tests so take my opinion or leave it.

Secondly some tips:

  1. If you are building multi-modular applications avoid doublicate configurations, otherwise you will often be stuck wondering why some changes don't take effect.
  2. The code hasn't changed that much, zf2 hasn't been rewritten from scratch with a few exceptions, so you will often end up wondering what's up with all the fuss about zf2 being hard to start with 
    $error = false;
    $return = $this->params()->fromQuery('return');
    if($this->getRequest()->isPost())
    {
    	$username = $this->params()->fromPost('username');
    	$password = $this->params()->fromPost('password');
    	$return = $this->params()->fromPost('return');
    
    	if($username != '' AND $password != '')
    	{
    		$adapter = $auth->getAdapter();
    		$adapter->setIdentity($username)
    				->setCredential(hash('SHA256', $password));
    
    		$result = $adapter->authenticate();
    		if($result->isValid())
    		{
    			$auth->getStorage()->write($adapter->getResultRowObject(null, 'password'));
    			if($return)
    			{
    				return $this->redirect()->toUrl(base64_decode($return));
    			}
    			return $this->redirect()->toRoute('default', array('controller' => 'index', 'action' => 'index'));
    		}
    	}
    	$error = true;
    }
    

    zf2 vs zf1

    if($this->getRequest()->isPost())
    {
    	$username = $this->_request->getParam('username');
    	$password = $this->_request->getParam('password');
    
    	if($username != '' AND $password != '')
    	{
    		$adapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table::getDefaultAdapter());
    		$adapter->setTableName('user')
    				->setIdentityColumn('username')
    				->setCredentialColumn('password')
    				->setIdentity($username)
    				->setCredential(hash('SHA256', $password));
    
    		$auth = Zend_Auth::getInstance();
    		$result = $auth->authenticate($adapter);
    		if($result->isValid())
    		{
    			$auth->getStorage()->write($adapter->getResultRowObject(null, 'password'));
    			$returnUri = $this->_getParam('returnUri');
    			$this->_helper->redirector->gotoUrlAndExit($returnUri);
    		}
    	}
    	$this->view->loginFailed = true;
    	$this->view->returnUri = $this->_getParam('returnUri');
    }
  3. The default route you will find in the skeleton app is very basic, so to at least achieve the main function of zf1 default route /controller/action/id use the bellow route, it also supports extra query params, if you call the url helper with route name 'default/query'
    'default' => array(
    	'type' => 'Segment',
    	'options' => array(
    		'route' => '/[:controller[/:action]][/:id]',
    		'constraints' => array(
    			'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
    			'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
    			'id' => '([0-9]+)?'
    		),
    		'defaults' => array(
    			'__NAMESPACE__' => 'Application\Controller',
    			'controller' => 'Application\Controller\Index',
    			'action' => 'index',
    			'id' => false
    		),
    	),
    	'may_terminate' => true,
    	'child_routes' => array(
    		'query' => array(
    			'type' => 'Query',
    		),
    	),
    ),
  4. If you stepped on a bug there is a good possibility you are not the first one to discover it, check the zf2 github as much as possible.
  5. Use the zf2 classmap generator to make autoloading a hell of a lot faster.

 

That's all for now, i will continue posting about ZF2, my opinion about it has improved a lot since i started porting one of my old zf1 applications and check back maybe i will start posting some very interesting tutorials about Zend Framework 2

 

Day number two of porting this application to zend framework 2. I only had a couple of hours today but still i have a couple of things i actually want to talk about. I keep encountering things that are not that much different from ZF1 like Zend\Navigation or Zend\Paginator. I was quite surprised i got them working in seconds.

In the app i have a paginated list of documents, and below is how the code changed:

Zend Framework 1

$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$select = $db->select()->from('document', $orders)->order(array("$order $way"));
$paginator = Zend_Paginator::factory($select);
$paginator->setDefaultItemCountPerPage($perpage);
$paginator->setCurrentPageNumber($this->_getParam('page'));

Zend Framework 2

$db = $this->getServiceLocator()->get('db');
$select = new Select('document');
$select->columns($orders)->order("$order $way");
$paginator = new Paginator(new DbSelect($select, $db));
$paginator->setDefaultItemCountPerPage($perpage);
$paginator->setCurrentPageNumber($page);

 

 Which if you exclude all the Use Statements you have to add on top it's not bad, i actually think it pretty much the same. It would be nice to be able to get the Select object from the adapter but it's not a big deal. The second thing of the day was how actively the ZF2 is developed. I found a couple bugs today working with v2.0.3. The most important was with the Zend\Mvc\Router\Http\Query which was adding the controller, action and namespace parameters to the query string, instead of only adding the extra parameters it was receiving. But guess what download the latest version from github and voila bugs are gone. (Lithium are you there... ;p). That really made my day, i make it a habit not following popular trends or rooting for the underdogs, see my history. I started learning php with LDU cms probably the most unkown cms of all and now choosing Lithium for Komposta Core instead of one of the most popular frameworks like Zend or Symphone or CakePHP for pete sake. So it felt great to go from the disappointing moment  of finding a bug to see that i was fixed in a minute. People are whining how much ZF2 changed and that it got a bit Java-ish but today at least, in my mind ZF2 will succeed because of the active developers and contributors.

zf2.pngI 've been following zf2 from the very first beta versions mainly reading presentations, tutorials and occasionally i browsed the code especially the skeleton application to see how the project progressed. So far i wasn't very impressed with it, the common view as i understand it is that it's not quite there yet and that it needs to be refined more before people really start to jump in and port their old applications to the new framework.

Today thought i started porting my BA thesis application from ZF1 to ZF2 as i plan to extend it  and add new features. The application consists of 5 controllers, a few plugins/helpers and the main engine that produces automatic summarization for Greek language which is a bunch of filters also written in ZF1. Beside that there are Users and Administration systems in place to easily manage the internal data.

I actually managed to accomplice more than i thought for day one. I got the front-end controllers and the summarization engine working with ZF2 quite easily. But still some things really bothered me. The most annoying thing of the day is the new Zend\Db it's obvious that they tried to enforce the Model part of the new MVC concept and it's not there not by a mile not when you have to inject every custom model with the TableGetAway which has to also be injected with the Db\Adapter.  

class Module
{
    // getAutoloaderConfig() and getConfig() methods here

    // Add this method:
    public function getServiceConfig()
    {
        return array(
            'factories' => array(
                'Album\Model\AlbumTable' =>  function($sm) {
                    $tableGateway = $sm->get('AlbumTableGateway');
                    $table = new AlbumTable($tableGateway);
                    return $table;
                },
                'AlbumTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Album());
                    return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
                },
            ),
        );
    }
}

I am pretty sure there is a smarter way to go that people already use in their modules but that official example is a joke. In my case there are about 4 mysql tables and in the current code base so i didn't bother with models since the system is quite predictable about future features and queries so i prefered the direct approach, here is an example of ZF1 vs ZF2 for running raw queries.

 Zend Framework 1.11

$db = Zend_Db_Table::getDefaultAdapter();
$docu = $db->fetchOne("SELECT COUNT(*) as unprocessed FROM document WHERE processed = 0");

Zend Framework 2.0.3

$db = $this->getServiceLocator()->get('db');
list($docu) = $db->query("SELECT COUNT(*) as total FROM document WHERE processed = 0")->execute()->current();

So my first day wasn't very positive. It was easy to port basic stuff and start working but on the other hand i am not seeing many advantages so far. Keep in touch as i will post daily about my experience with zf2.

When i started komposta CMF two months ago i focused mainly on backend development and i gladly accepted twitter bootstrap benefits. It is so easy to capitalize on how complete it is and apparently i wasn't the only one who thought so. But there is a huge catch, designers are getting lazy, and so many sites look alike, it's like brainwash, hence the title of this post. 

With Joomla 3.0 and the new bootstrap facelift things are going to get worse. There are at least a couple more open source projects, as far as i know, undergoing the same UI surgery. Until B.B (before Boostrap) you could unmistakably guess what cms/blog sytem a site was using which is bad but the huge variety of apps out there balanced things out.  A.B (after Boostrap) things are looking grim for internet unique looks.

I had decided i would do something about boostrap as soon as komposta would reach a satisfying level of features. In the beginning as i was mesmerized by bootstrap awesomeness i decided to build on it. That unfortunately doesn't work, you end up with a bad camouflaged look which doesn't really give a unique look, and you still have to use html mark-up that you might not even like.

The solution for me was to pick the most important components of Bootstrap or any other CSS Framework you choose and start from there. Writing on top of the full package is impossible because firstly bootstrap is already huge. With all the components it's about 0.20MB with the custom css to camouflage it you will end up with 300Kb just for CSS not including images or other 3d party JavaScript libraries. Secondly you have to live with the suggested mark-up like it or not. The number one thing you must not use are the Buttons+Navigation components, it's the number one identity give away clue. The complete list of components i used from bootsrap:

  1. Normalize (not really bootstrap's)
  2. Typography (with 13px/18px font-size/line-height)
  3. Tooltips
  4. Breadcrumbs
  5. Alerts
  6. Form bits

It's not like i couldn't live without them but for me that's the minimum setup. For the form bits i used only the absolute necessary styling from BT and i changed the HTML Markup to Definition Lists (<dl>) which i think is more appropriate. 

Now some of the downfalls. You will probably end-up with quite a huge list of bugs and serious issues with older browsers for a less pleasing look at least in the beginning. But i promise you won't regret it and you will be able to use components and stuff from various sources, making your creation unique at least in the eyes of your none designers visitors ;p

 kompostaPhrasesAB.png kompostaOptionsAB.png kompostaLogsAB.png

 

What do you think ?

Btw i added a much needed contact form at the top if you need to reach me.

The idea of building a cmf came to me 2 years ago, at the time i wasn't into php frameworks, i intended to build it from scratch and i came very close to a release candidate a year ago but my pet project had to be put on hold. I started work at Greek Ministry of Education and i was involved on a lot of web projects and to speed up the procedure i choose Zend Framework as the industry standard choice. That's when i fall in love with php frameworks. Zend 1.11.x was easy to work with, it didn't bound the programmer to follow a strict path and had (probably still has) a huge variety of libraries to accommodate any programmers need. Another big factor on choosing Zend was the excellent documentation and on-line sources.

Six weeks ago when i decided to restart my pet project i had to choose between continuing with my php framework or go Zend. Unfortunately my php framework had to die young because i wanted to have something ready for production this year. Zend framework 2.0 was well under the way but at the time only beta versions had surfaced. I have to admit that after peaking at the source code of ZF2 i wasn't impressed but i won't comment on it until i have the time to check the stable version that was released last week.  

After that i was on a php framework hunt and limited the options pool to Symphony2, Kohana and Lithium. I quickly eliminated Symphony because it looked like it has a very steep learning curve. Kohana, although i promise to keep in touch, is lacking in cutting edge PHP features. After quick tests i was impressed with Lithium. It's relatively small and fast, it doesn't impose stupid restrictions to the programmers and has a better than good in-house Data Model solution. Of course it has some grey areas but because it's so flexible you can bypass any problem or bug easily.

But i have to admit the number one reason for my choice was the news about Lithium getting sponsored by Engine Yards. Honestly Lithium development has slowed down a lot this year and until the news from Engine Yards i wasn't sure if Lithium was dead or alive. Documentation is sketchy at best, online sources are limited and git support is, well hrm... If you are new to php go with a framework with good documentation and community like CakePHP, otherwise be prepared for a lot of code reading or stay tuned, lithium tutorials are on the way...

Hello my name is Chris i am 26 years old, i am a web developer with almost ten years of experience in php and mysql. This site is my personal blog/portfolio. In the past i developed plugins, templates for applications like LDU/Seditio (R.I.P), wordpress, joomla, phpbb, vbulletin and Xbits, you might have stumbled upon me on T3-Design.com where everything used to happen. The last couple of years i was in an on-line hiatus because i was determined to finally take my degree in computer science from the Technological Educational Institute of Athens. This site is my come back to active duty if you will. For this endeavour to succeed i needed to start over from scratch

In the beginning, back in 2005, T3-Design.com was powered by ldu , seditio later and finally wordpress. For years i loathed to have my own base application that i will be able to use for my projects and ideas. For komposta.net i decided to go all out and did that. I started my own CMS or what i prefer to call it CMF,  content management framework. It's called Komposta CMF and as i write this post it's only 96 commits old and hopefully i will make it public later this year.

In the past year i worked a lot with Zend Framework. These were probably the most productive months in my career, so using a php framework was only natural. After research and a lot of consideration i picked Lithium to be the brute force behind komposta for reasons i will explain later...

More info about the Komposta is coming soon for now just have a look

 routes.png resources.png options.png mainSettings.png cron.png adminNavigation.png

I will slowly add all the content from T3-Design for those who miss it, for now just step in and leave a comment please!