Introducing The CocoFramework PHP

Hello everyone.

Last entry I wrote had been several months ago and had no time to write more.

Today I’m glad to announce  my big project CocoFramework, that I’ve been developing for more than three years and that started as a solution to the problem of developing a website.

You can check the code at

What is the CocoFramework?

Coco is my PHP Framework project, the result of years working hard and learning to code better and also learning webpage and webservices scalability.

Coco is a full lightweight PHP framework that provides the following components:

  • It’s free OpenSource and its PHP >=5.3 compatible
  • Very customizable, easy and handly URL routing system
  • HMVC (Hierarchical Model View Controller) design pattern to implement bussiness logic and application logic.
  • Front Controller implementation to serve and dispatch the requests
  • Authentication with HTTP_AUTHENTICATION, Database and .htaccess Role-Based authentication support.
  • Supports a large sets of RDBMS systems (via PDO driver) and now will suport MongoDB NoSQL database.
  • ActiveRecord implementation for making easy to deal with business objects
  • Easy to implement RESTful webservices, even to create an XML or JSON based replies or any MIME type replies (can serve images, PDFs o wherever you need to serve in your business). Also helps to
  • Cache interface to help caching and retreiving data from 5 different cache backends.
  • Fast results and good performance (arround 25ms ~ 180 Requests/Second by request using a dual core AMD 64 Bit CPU and NGINX), the best performance is with a i7 wich show up to 700 Requests/Second using Nginx and a 500 concurrency level (tested with Apache Benchmark).
  • Some APIs (Google, Yelp, Twitter … ) incoroporated to start integrating them in minutes.
  • 32+ Framework Components and growing
  • Cron tasks supported
  • Flexible configuration files and routing files based on fast PHP array parsing.
  • Extremely easy to localize your website in multiple languages.
  • Very flexible views and layouts system wichs allows developer to develop the application with extremely coding reuse and helps the developers to keep common functionalities and views in one place and use everyplace is required.
  • SOAP services supported (now deprecated, but will return if anyone wants to use them).
  • More than 20 Software Design Patterns applied into the code.
  • OpenSource  BSD-like license.

Why the name of CocoFramework?

Choosing a name is not an easy task for me, so I’ve been thinking in a way I can make a name wich had to be easy to remember and pronounce and also internationally speaking has the same meaning.

But I’ve doesn’t want to name it Coco because of Cocos, I want to name it Coco because our cat whose name is Coco and its the curious animal in the earth I love cats and I love my girlfriends cat, I’m a cat-maniac, so I’ve choose to name this project Coco because of my girlfriends cat and having a name that isn’t already registered.

Coco, my girlfriend's cat

Coco, my girlfriend’s cat

Some CocoFramework history

It was the second quarter of 2006 when I was studying computer science engineering at Universitat Jaume I in Castelló de la Plana (Spain) when in the students association we needed a webpage to make and manage the information and activities for the “Welcome Week ” for new students that the university makes every year  in the month of October.

I’ve started coding PHP that I learned in a crash course of 10 hours from my FLOSS group at that university and begin coding seriously in PHP and HTML, but soon arrived to a point where my code was hard to debug and not easy to find the errors of a beginner who was starting coding its firsts own programs and websites.

After the website was coded and the event was ended I began working in the code to wrap it in packages, separate the logic and the database access and also starting learning AJAX and JavaScript to make webpages easier and beautiful.

But wasn’t until july 2008 when I’ve already left Universitat Jaume I and moved to Universitat Politècnica de València (nearest to my home) and collaborating with that students organitzation I redeveloped the 2006 website using my new knowledges of coding and design patterns that I learned at València. This point is where I begin coding the very first version of CocoFramework. That version started using MVC (Model View Controller) and some design patterns as the Singleton or the Front Controller but started without a missing piece (in that moment) that has powered the framework with extensible and very customizable URLs, that piece is called the “Router”.

After October 2008 I’ve started to think in rewrite my code with the help of my university professors who where teaching me Software Engineering, Software Design Patterns and Extreme Programming. They’ve began helping me to develop the start of the CocoFramework version of 2009 and 2010. They’ve  encouraged me to keep writing code and develop it for the final degree project,  a project whose every student has to develop for obtaining the degree.

After three full rewrites of the framework in 2009 I’ve began to put more and more time into the framework, while I was adding a database layer, making the domain objects using the Active Record design pattern, separating the MVC controllers and models and grouping them into modules and also writen the plugin interface.  Later in 2010 when learned webservices I’ve began to incorporate some RESTful and SOAP helpers to make the actions of the framework be working as webservices, then starting coding the Authentication layer and refactoring everyday the classes of my framework to achieve a better result and perfomance. But wasn’t until 2010 that I’ve was writing the final degree memory when the CocoFramework suffered two more full rewritings. One was for migrating XML file routing to a PHP arrays based description routing system and the other is because I was worried about the poor performance of serving a webpage in near 200ms.

During the first two quarters of 2011 I was rewriting and refactoring some components and going happier everyday because I was winning in performance and speed, that in that moment was arround 70ms to do a simple request.  Finally in July 2011 I’ve finished writing the Final Degree memory (that is 315 pages length) and stopped working in the framework for many months.

Then while triying to start working as a freelance (unsatisfactorily due to clients that won’t have payed me yet) I used the CocoFramework to make the client website (a real estate social network and services page), and so rewriting more and more some of the components to adjust them to the performance I’ve need to achive in that work. After six months working hard for that client, they’ve breaked the working relationship and I lost some money, and working time (I’ve been paid half the project during the first week working with them, so losing only the half of the project), and also losing motivation to continue working.

After three months of rethinking, reconsidering and with my friends encouraging me to start again and begin thinking of an startup I’ve started working again in the CocoFramework and after some code cleaning I’ve published it on Github.

And this was a week ago, I’ve been working since there to keep it going and better.


Contributing to CocoFramework PHP

If you want to contribute with the project, please contact me at andresmartinezsoto NOSPAM or at @andreums twitter account.

The project is open for everyone who wants to contribute and make it better.

Anyways, if you have any doubt I’ll be glad to reply and help you.



You can check the code at

Or review my CocoFramework Old version code at

Thanks for following me! Thanks for reading me!

[PHP] [Maps V3] Cheking if an StreetView panorama exists for a location


Last days, while working in a project I’ve got the need to check if a streetview panorama was available for an exact address or a LatLng location for showing (or not) an streetview panorama in a webpage.

Reading and checking the API for StreetView ( and having the need to check the existence or not of a panorama using PHP, I began to observe Google Maps behavior and HTTP Requests.

While moving the StreetView symbol (the orange man), I realised that Google Maps was making a request to a service wich returned the data of the panorama or an empty document in case that a panorama for the location isn’t available. Discovering that request, gave me the opportunity to know exactly what I want and let me implement the behavior that the application needed without showing the customer a gray image that StreetView displays when no panorama is available at the selected location.

Endpoint Calls to check if a StreetView panorama is available

Google Maps makes requests to the following endpoint of their API to check whether a StreetView panorama is available or not:,-0.3899&radius=50&cb_client=maps_sv&v=4

In the endpoint some parameters could be observed:

  • output: The format of the result, that can be only XML or JSON (we’ll choose json for easier processing with PHP)
  • hl: The language of the request (in this case en means English)
  • ll: The exact pair Latitude-Longitude separated by a comma
  • radius:  This parameter is something like a “distance from the point to the observer” that the point can be observable and have a StreetView panorama available.  The lower this value is the closest view that can be obtained for a StreetView panorama (0, zero in this case). The default value seems 50, and the units seems that are in meters.
  • cb_client& v: The client that requests the data and the version of that client.

Calling the endpoint in PHP

For calling this endpoint we’ll be using PHP 5.2+ and the Curl Library . Be sure to have this library installed in your developing machine or your hosting (in Ubuntu is as easy to install as typing sudo apt-get install php5-curl ). After installed or a test that shows Curl is working properly, we’ll write some code to make an HTTP Request to the explained endpoint and check if a panorama is available or not.

$endpoint = ",-0.3899&radius=10&cb_client=maps_sv&v=4"
$handler = curl_init();
curl_setopt($handler, CURLOPT_HEADER, 0);
curl_setopt($handler, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handler, CURLOPT_URL, $endpoint);
$data = curl_exec($handler);
// if data value is an empty json document ('{}') , the panorama is not available for that point
if ($data==='{}') {
print "StreetView Panorama isn't available for the selected location";

I know the panorama is available but this returns it isn’t!

If checking only with a value of 10 in the radius parameter of the endpoint doesn’t gets a positive response, be trying some values for that parameter. I’ll recommend from 10 to 75 in steps of 10, 25, 50 and 75. But think that a StreetView panorama from 50 meters (or more) could be far away from the point that you need to show, and you need exactly that point, not a view from 50 meters of that point.


Is possible to check if Google has a StreetView panorama of an exact LatLng location with one meter radius precision with little effort and this trick.

How is possible that Google hasn’t put any method on the API to check that existence?  Can Google add some information in a Google Maps V3 Geocoder that could tell a developer of that existence?  It’ll be a lot easier by only checking the data received of the Geocoder and not having to do this trick.

Thanks for reading.
If you have any questions or have more information/another way to check existence in PHP/JS, please don’t mind to contact me using the comments of this post.

Andrés Ignacio Martínez Soto

Y con esta entrada queda (re)inaugurado el blog

Y con esta entrada queda (re)inaugurado el blog…

Hace muchísimo tiempo que, por falta de ganas, demasiadas obligaciones o tiempo no he escrito nada. Terminada esa época, con más conocimientos que nunca y algo más viejo, quiero retomar la escritura sobre mi mundo. Quiero compartir con vosotros recetas de programación,  diseño y desarrollo web, así como muchos otros temas.

Ayer terminó una época dura y larga de mi vida, que se ha prolongado durante los últimos cinco años, así que tras un alto en el camino, bienvenida sea la nueva etapa de mi vida. Etapa en la que intentaré hacer todo mejor, juntar todo lo aprendido y seguir creciendo en todos los campos de mi vida y junto a mi pareja. Adelante, pues.

Buenas noches a todos


WTF-La Pista (What The Plato)

Restaurante “La Pista” , Xaloc, Alacant, España

Hello world!

Welcome to This is your first post. Edit or delete it and start blogging!

Transparencias del seminario “Introducción a Python” (20/11/2008)

Tras una larga espera … las transparencias del seminario de formación “Introducción a Python” impartido en el Aula B5 de la ETSIAp el 20 de Noviembre de 2008 en el marco de los Seminarios de Formación de PolinuX.

Cualquier pregunta, duda, crítica, felicitación … poned comentario


Licencia de la presentación

Usted es libre de:
Copiar, distribuir y comunicar públicamente la obra
hacer obras derivadas
Bajo las condiciones siguientes:
Reconocimiento: Debe reconocer los créditos de la obra de la
manera especificada por el autor o el licenciador de la misma,
además, le deberá comunicar al autor el uso de su obra
No comercial: No puede utilizar esta obra para fines comerciales
Compartir bajo la misma licencia: Si altera o transforma esta obra,
o genera una obra derivada, sólo puede distribuir la obra
generada bajo una licencia idéntica a esta
Al reutilizar o distribuir la obra, tiene que dejara bien claro los
términos de la licencia de esta obra.

Transparencias del seminario de formación “Descubriendo SQLite3” (23/04/2009)

Aquí os dejo las transparencias utilizadas en el seminario de formación “Descubriendo SQLite3” que impartí el pasado 23 de Abril de 2009.

Licencia de la presentación

Usted es libre de:
Copiar, distribuir y comunicar públicamente la obra
hacer obras derivadas
Bajo las condiciones siguientes:
Reconocimiento: Debe reconocer los créditos de la obra de la
manera especificada por el autor o el licenciador de la misma,
además, le deberá comunicar al autor el uso de su obra
No comercial: No puede utilizar esta obra para fines comerciales
Compartir bajo la misma licencia: Si altera o transforma esta obra,
o genera una obra derivada, sólo puede distribuir la obra
generada bajo una licencia idéntica a esta
Al reutilizar o distribuir la obra, tiene que dejara bien claro los
términos de la licencia de esta obra.

View more presentations from andreums.

Espero dudas, comentarios, quejas, sugerencias …

pd: Tengo vídeo del seminario que en cuanto haya un hueco grande (verano) lo montaré y lo subiré a youtube.

%d bloggers like this: