Posts tagged Tools

clphped

Free PHP, HTML, CSS, JavaScript editor (IDE) – Codelobster PHP Edition

2

Introduction

I do not normally post anything related to IDE’s but I thought this article was worth as it supports Yii :) as one of the frameworks of the IDE. Thought this could be a good IDE for those Window Yii’ers out there.

Codelobster

For valuable work on creation of sites you need a good comfortable editor necessarily. There are many requiring paid products for this purpose, but we would like to select free of charge very functional and at the same time of simple in the use editor - Codelobster PHP Edition.

Let us consider some important possibilities and advantages of this program:

  • All code highlights depending on a type, the also mixed code is thus supported, so the area of HTML will be highlighted as HTML, PHP as PHP, and Javascript as Javascript in a the same file. Thre is possibility of choice from color schemes, including popular IDEs.
  • Powerful autocompletion for HTML, PHP, CSS and Javascript, including HTML5 and CSS3. For PHP the structure of project is fully recognized, and the complete list of methods falls out in the proper places.
  • HTML/CSS inspector on the type of Firebug, which allows easily to correlate the selected elements of page with a code and proper style.
  • Context help on all supported languages. By pressing F1 key the page with detailed description for current tag, attribute or function will be opened.
  • PHP debugger. PHP debugger allows to execute PHP scripts incrementally, watching the values of all variables in every line.
  • SQL manager allows to produce all necessary actions with a database – to add, delete, edit a structure and records in tables, to export data, execute SQL queries. Highlighting and autocompletion works for SQL files also.
  • Support of FTP allows to work straight with a remote server and to do all necessary changes with files;
  • The portable option allows to use editor without the preliminary installation.
  • Other useful utilities: pair highlighting, possibility of blocks selection, collapsing, tooltips, navigation on descriptions of functions and included files at withholding of the key of CTRL, viewing of structure of files and project, preview in a browser, book-marks, and all other standard possibilities for work with a code.

Also there are special plugins for work with

  • CMS: Drupal, Joomla
  • PHP frameworks: CakePHP, CodeIgniter, Symfony, Yii
  • JavaScript libraly: JQuery
  • WordPress blogging engine
  • Smarty template engine

How to work with Yii and CodeLobster


Tweet this!Tweet this!
yiia-twitter-logo

Yiianswers, a new site for yii lovers

0

I would like to introduce a new site that a good friend of mine and work colleague Maurizio Domba (mdomba) and I have setup in order to solve an issue that actually occurs at the Yii forum and help the Yii community with what we think could be a great tool for their learning or development processes: Yiianswers.com

Don’t get us wrong, the forum is amazing, highly addictive (you can check our profiles -mdomba an tonydspaniard to find out how we love that forum) and very useful thanks to the support of a lot of good programmers that freely give aways their time to help others get the right answers, in order to push Yii to the level where it supposed to be in terms of PHP community acceptance.

Nevertheless, one of the things that we face as the forum grows is that the same questions are repeated again and again, and we believe that this is not because users do not know how to search for a solution but for the structure and functionality of a forum itself. We always thought that could be great to have a site to keep questions and its solutions in a categorized tree where people could easily browse, search, and/or find what they are looking for, and this is why Yiianswers.com is here.

Yiianswers.com is an instant Questions and Answers site, so popular nowadays. We really hope that will help you out and will easy the task of finding the right answers to your Yii questions.



Tweet this!Tweet this!
create-professional-invoices-for-free-invoice-bubble

Invoice Bubble -Create Professional Invoices for Free

0

I have lately found a very interesting service for those who work as a freelance to create really cool invoices; it is called Invoice Bubble.  With this service, which is totally free (it inserts some ads that can be removed by paying a very low monthly fee $5 USD), you can create your own invoices, send them to your clients and get paid via Paypal.

It is quite good and has an excellent design; also, you can create recurring invoices and keep track of the payments from the control panel.

Tweet this!Tweet this!
Captura de pantalla 2010-09-12 a las 12.00.32

Less Framework 2

0

All of us know how hard is to get a proper CSS layout for our pages. Thanks to 960 grid system we developers were able to solve some of the issues that we face when we design for different browsers. Now, new devices coming aboard such as Android, iPhones, Blackberry’s and their browsers and the nightmare continues. Nevertheless, nice people like those of 960 grid system give away their approaches and solutions in order to make our life’s easier. Less Framework 2 comes to help us:

A CSS framework for cross-device layouts

Everyone writes CSS differently. Less Framework takes this into account by having a minimal set of features, and does away with things like predefined classes.

No more 960 px

Less Framework uses inline CSS3 media-queries to switch between three layouts:

  • a two-column layout at 320 px, for smartphones
  • a five-column layout at 768 px, for iPads and netbooks
  • and an eight-column layout at 1280 px, for desktops and laptops.

No hacks, unless you want them

Less Framework works beautifully in Firefox, Chrome, Safari, Opera, IE9 (hopefully), Android phones, and all iOS devices (that’s all iPhones, iPads, and iPod Touches). It even behaves nicely in landscape mode.

Tweet this!Tweet this!

Yii Framework

Yii Framework -Final Decision

2

I never felt comfortable with external libraries, those created by other people. Always, since my old times with Visual Basic, have created my own and until now, everything I created was good enough but… Suddenly, after I found that marvellous library called RedBean, I found my self re-programming all my libraries and end up creating a controller and a base model class for a sort of MVC library – I will post it one of these days so you guys can look at it and find out how easy is to implement that incredible library is (thanks Gabor de Mooij!) on your libraries.

But, as a programmer, I started to think that, even though my own libraries speed up my development processes, I want it to be hands on a bigger and more ambitious projects -that happened long time a go but never felt impressed by any library out there. My libraries lacked on scalable development architecture and had to find for a better solution for a much bigger project I am jumping right now. I google around and found interesting offers as exposed on one of my old posts:

Actually, far too many, so I took my time to decide for one to suit all my needs. Checked around and read some good articles about Yii framework and then, telling the truth, I was very impressed with (information taken from http://programmersnotes.info:

  • 100% OO architecture. It is really good application design.
  • Authentication & roles mechanism
  • Caching techniques
  • DB access, which is based on PDO
  • Active record and relational active record implementation
  • Validation – that is really, really nice. To create quite complex register form (check if login is unique, if email is unique, email match with confirmation, passwords match, validate integer/string values, check empty fields and give nice error messages for each field you need only template (view) and model with rules defined. It took me 10-15 mins to do that!)
  • Component concept. Just to give an idea, why is it nice – you can define getter and setter methods for properties, you can define read-only properties for components, define and invoke events, attach event handlers and additional features to the class without modifying it, just by attaching additional behaviour to it
  • Also, check its graphical benchmarking against other MVC frameworks http://www.yiiframework.com/performance.

Wondering whether DooPHP (claiming is the fastest at the moment) or Yii, I finally decided to use the latest due that DooPHP is quite new and Yii has a huge amount of features and tweaks that, even its documentation is not the best (I just read their Definitive Guide and I think I will have to read to a couple of hundreds articles more to be ‘good’ at it), I think at the end will become the Toolset for highly scalable projects -using its automation tool called Gii, I did the skeleton of a project in less than 30 seconds -duh!.

In addition. last but not least, you can integrate Zend components easily and jQuery is nativelly implemented -and I loooooove jQuery.

For the small ones I still like my own libraries though :)

Tweet this!Tweet this!
open-source

Uri Class for PHP

0

For years, we developers tend to keep functions that we find useful into our projects, after certain time they become obsolete or you move one to higher level ways of programming. Some of us, can’t get rid of the code that was once collected-created and I thought let’s see if I post one of my silly old classes what can we get out of it? Let’s make it open source hahahaha.

I propose you the following: Here is my small old good set of Uri PHP functions encapsulated into one class, I know is not a great deal but, let’s see what can we all do with it. For every programmer that posts a function, I will write his reference into the class and post his/her site link in this post.

There are certain rules though:

  1. Functions cannot be greater than 20 lines of code
  2. Functions cannot depend of far too many external components (maximum one)
  3. If functions depend of an external component/class, a URL indicating its reference must be provided
  4. Functions are not to be repetitive, if there is one better written that the ones exposes we will replace it

The Uri Class

Here is my class:

<?php
/**
 * @author Antonio Ramirez <contactme@atmyblog.com>
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @link http://www.ramirezcobos.com/
 *
 *
 */
class Uri
{
	/**
	 * Encodes the parameter to hide
	 * its contents to user
	 *
	 * @param string $val
	 */
	function uriEncode($val)
	{
		return rawurlencode(base64_encode($val));
	}
	/**
	 * Decodes a parameter string that
	 * was previously encoded with uriEncode
	 * function
	 *
	 * @param string $val
	 */
	function uriDecode($val){
		return base64_decode(rawurldecode($val));
	}
	/**
	 * Translates a given url to
	 * tinyurl version -curl required
	 *
	 * @param string $url
	 * @access public
	 * @return string $data
	 */
	function getTinyUrl($url){
		$ch = curl_init();
		$timeout = 5;
		curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
		curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
		$data = curl_exec($ch);
		curl_close($ch);
		return $data;
	}
	/**
	 * Translates a given url to
	 * ToLyUrl version -curl required
	 *
	 * @param string $url
	 * @access public
	 * @return string $data
	 */
	function getToLyUrl($url){
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, 'http://to.ly/api.php?longurl='.urlencode($url));
		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
		curl_setopt($ch, CURLOPT_HEADER, 0);
		$data = curl_exec ($ch);
		curl_close ($ch);
		return $data;
	}
	/**
     * Gets Request param
     *
     * @param string $paramName
     * @param string $slash
     * @access public
     * @return string $param or boolean $false
     */
	function getParam($paramName, $slash=false)
	{
		return (isset($_REQUEST[$paramName])?($slash?addslashes($_REQUEST[$paramName]):$_REQUEST[$paramName]):false);
	}
	/**
     * Serializes Request params
     *
     * @param string $notThisOne
     * @access public
     * @return string $query_string
     */
	function getParams($notThisOne=false)
  	{
		global $REQUEST_METHOD, $HTTP_GET_VARS, $HTTP_POST_VARS;
		$query_string='';
		if (strpos($_SERVER['REQUEST_URI'],"?"))
		{
			list($fullfile, $voided) = explode("?", $_SERVER['REQUEST_URI']);
			$cgi = $_SERVER['REQUEST_METHOD'] == 'GET' ? $HTTP_GET_VARS : $HTTP_POST_VARS;
			reset ($cgi);
			while (list($key, $value) = each($cgi)) {
			  if ($key != $notThisOne)
				$query_string .= "&" . $key . "=" . $value;
			}
		}
		return $query_string;
  	}
	/**
     * Makes a Soap Call
     *
     * @param string $uri
     * @param string $command
     * @param string $xml
     * @access public
     * @return string $response
     *
     * Requires Soap
     */
	function makeSoapCall($uri,$command,$xml)
	{
		try{
			ini_set('default_socket_timeout',10); // ten seconds, that is all we wait
			$client = new SoapClient($uri,array("connection_timeout"=>10));
			$response =  $client->__soapCall($command,array(new SoapParam($xml,'Peticion')));
		}
		catch(Exception $e){
			$response = false;
		}
		return $response;
	}
	/**
	 * Parses a given $url for validation
	 *
	 * @param string $url
	 * @access public
	 * @return $parsed_url
	 */
	function getParsedUrl($url)
	{
		$parsed_url = parse_url($url);
		if (!isset($parsed_url['scheme']) or $parsed_url['scheme'] != 'http'){
			echo 'Unsupported URL sheme given, please just use "HTTP".';
			exit();
		}
		if (!isset($parsed_url['host']) or $parsed_url['host'] == ''){
			echo 'Invalid URL given!';
			exit();
		}
		$host = $parsed_url['host'];
		$host .= (isset($parsed_url['port']) and  !empty($parsed_url['port'])) ? ':'.$parsed_url['port'] : '';
		$path = (isset($parsed_url['path']) and  !empty($parsed_url['path'])) ? $parsed_url['path'] : '/';
		$path .= (isset($parsed_url['query']) and  !empty($parsed_url['query'])) ? '?'.$parsed_url['query'] : '';
		return 'http://' . $host . $path;
	}
	/**
     * Requests a Url and returns its contents
     *
     * @param string $url
     * @access public
     * @return string $query_string
     * @uses Snoopy class http://sourceforge.net/projects/snoopy/
     */
	function getUrlContent($url)
	{
		App::import('component','snoopy');
		$url = Uri::getParsedUrl($url);
		$snoopy = new Snoopy();
		$snoopy->agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; es-ES; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12';
		$snoopy->referer = '';
		$results = false;
		if($snoopy->fetch($url)){
			$results = $snoopy->results;
			// empty buffer:
			$snoopy->results = '';
		}
		return $results;
	}
}
?>
Tweet this!Tweet this!
redB

RedBean ORM

1

I was breaking my head towards to find a better ORM approach for my own written framework. I used, and was very happy with P.O.R.K., for quite long time but, as most of us, I was looking for something that could improve the speed of my projects. P.O.R.K. configuration is not hard at all, it is compound of a set of classes encapsulated in three files that allowed me to create models in sort of ActiveRecord style and was really, really good when I first started.

Now my projects are bigger, require a lot more of database analysis and those sometimes go up to 30 tables or more. That means that once analysed a project, I had to create those tables in the database, specify their fields and so on… you know.

I found my self into the lazyness mode and I was already thinking that it could be great to create a set of libraries that do not require any configuration files at all and could manipulate my databases in such a way that not only queries for data but also dynamically creates the tables for me if they do not exists. That could save me around one or two days of work I thought…

Before creating anything I ask mr ‘Google’ if there was something around that could match my concept (never reinvent the wheel) and OH MY… I found it, its name is RedBean and I have to say that is one of the greatest libraries that have ever came across.

How it works

Create a database

Include the required files to work with RedBean -one file: redbean.inc.php

include('mypathto/redbean.inc.php");

Access its core:

//Assemble a database connection string (DSN)
$dsn = "mysql:host=localhost;dbname=mydatabasename";
//Connect to database and fetch the toolbox; either with password
$toolbox = RedBean_Setup::kickstartDev($dsn, $username, $password);

Now, just for this example: creating one Bean

$rb = $toolbox->getRedBean();
// lets create one object that we didnt even declared anywhere :)
$post = $rb->dispense('post');
// set some variables -fields
$post->title = 'This is magic';
$post->created = date('Y-m-d');
// save newly created object to database (how come?)
$rb->store($post);

If we were to look onto our database, we will find now that a new table is created called ‘post’ and your bean has successfully saved its properties.

Of course, this is a silly example, in my case I am using redbean on a MVC ‘modified’ pattern (I don’t like the ‘View’ part as it is implemented in modern frameworks and for small projects I use my own approach). Please, have a look to its manual, trust me, it is worth a try.

From the deep of my heart, THANKS for such a great job to his developer mr (Gabor) de Mooij. At last, one EASY yet POWERFULL library for our projects that really help us saving developing time.

Tweet this!Tweet this!
add-images-to-gallery

Visual Lightbox

0

This post is for those who wish to implement a beautiful Lightbox plugin on their site or blog and, unfortunately, do not have a clue about Javascript and/or jQuery and/or Html.

VisualLightBox is a free application that helps you easily generate online photo albums, lightbox gallery with a nice Lightbox-style overlay effect, in a few clicks without writing a single line of code.

Just drag&drop your photos to VisualLightBox wizard window, press “Publish” and your own css web site album with beautiful LightBox effects will open in the browser instantly!
No css, image editing, javascript, html coding, just a click to get your cool web page album ready.

It takes less than a minute to have your own image gallery.

For full documentation please go to http://lightbox2.com/

Newbies, now there is no excuse to have your featured lightbox on your site!

Tweet this!Tweet this!
 

Php Frameworks

1

I decided to jump over the MVC (Model View Controller) pattern and on one of my linkedin groups I drop a question:

Which one is best?

A huge amount of PHP programmers started to join this discussion writing their personal PHP Framework tastes, providing me with a huge list of Frameworks I would like to share with you. I don’t say that one is best that another, as one of the members said, there is no ‘best PHP MVC Framework, is whatever suits you best on your project goals’.

I know the list could be much bigger, if you know more PHP Frameworks to add to this list, please comment and I will update it.

Tweet this!Tweet this!
 

Get Latitude and Longitude with Google Maps V3

7

I would like to share with you a little piece of code that I find quite useful in my applications. I do create lots of guides that require a small utility to find out the latitude and longitude of a business location from a control panel in order to display the maps appropiately on the Web. Here I will do my best to explain a step procedure on how to do that -once you know the procedure, it is easy to create plugins or whatever you wish to do.

Step 1

First of all, lets make a reference to the new version of Google Maps. Check that we have to specify a parameter sensor=false. To find out more about this parameter please follow this link.

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

Step 2

Now we are going to write the HTML tags on the BODY of our document that will hold the map and the controls that will hold latitude, longitude and zoom level references. Also, see the CSS that control the size of the map holder.

<style>
div#gmap {
width: 100%;
height: 300px;
}
</style>
<body>
<center>
<!-- MAP HOLDER -->
<div id="gmap"></div>
<!-- REFERENCES -->
lat:<span id="lat"></span> lon:<span id="lon"></span><br/>
zoom level: <span id="zoom_level"></span>
</center>
</body>

Step 3

Now, we are going to write the function that will display the map when the document loads. The function, that we will call ‘initialize’ has different parts that we will describe now:

Part 1

Setting the map zoom level and its position in the world:

var myLatlng = new google.maps.LatLng(38.971154274048345,1.415863037109375); // IBIZA :)
var myOptions = {
zoom: 16,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("gmap"), myOptions);

Part 2

Placing a marker on the map specifying its center position (please refer to above code for LatLon location).

// marker refers to a global variable
marker = new google.maps.Marker({
position: myLatlng,
map: map
});

Part 3

Now, the events that will take control of the marker center re-positioning and placing the information on the correspondent document objects (lat, lon, and zoom level).

// if center changed then update lat and lon document objects
google.maps.event.addListener(map, 'center_changed', function() {
var location = map.getCenter();
document.getElementById("lat").innerHTML = location.lat();
document.getElementById("lon").innerHTML = location.lng();
// call function to reposition marker location
placeMarker(location);
});
// if zoom changed, then update document object with new info
google.maps.event.addListener(map, 'zoom_changed', function() {
zoomLevel = map.getZoom();
document.getElementById("zoom_level").innerHTML = zoomLevel;
});
// double click on the marker changes zoom level
google.maps.event.addListener(marker, 'dblclick', function() {
zoomLevel = map.getZoom()+1;
if (zoomLevel == 20) {
zoomLevel = 10;
}
document.getElementById("zoom_level").innerHTML = zoomLevel;
map.setZoom(zoomLevel);
});

Part 4

Initialize the document objects with default information

document.getElementById("zoom_level").innerHTML = 16;
document.getElementById("lat").innerHTML = 38.971154274048345;
document.getElementById("lon").innerHTML = 1.415863037109375;

Step 4

Finally, we have to write the function that will reposition the marker on ‘zoom_changed’ map event and call the ‘initialize’ function on window load event.

function placeMarker(location) {
var clickedLocation = new google.maps.LatLng(location);
marker.setPosition(location);
}
window.onload = function(){initialize()};

And that’s it, we have a great utility to plug onto our projects in order to find out the latitude and longitude of an address.

DOWNLOAD

I have included the working version of this tutorial for you to download. If you make any changes on the code in order to improve/add more functionality to it (that is easy fellows), please share it here with us.

http://www.ramirezcobos.com/wp-content/plugins/downloads-manager/img/icons/default.gif download: Get Lat Lon Finder (1.41KB)
added: 22/01/2010
clicks: 2539
Tweet this!Tweet this!
Go to Top