Posts Tagged ‘PHP’

Ultimate Collection of PHP Libraries

Having a collection of php libraries in one places will help you get your job done faster. It help me, so I share my list. I’ll keep update the list with more libraries.

Continue reading »

Submitting Form and Progressive Enhancement

Most users nowadays familiar with AJAX, well they don’t really know the term.
What users familiar is the experience, such as of submitting form without reloading the page.

So when you build new website or your web application, don’t forget to include this experience. But you also have to remember, there are some people who turn off their javascript or maybe the javascript failed to load. That is why, you should consider to use progressive enhancement.

In progressive enhancement, you can make your web application work in condition where no javascript available or failed, and enhance them if javascript available.

Lets just go with example, we’re building a form that will submit and reload to new page, but when javascript is available the form will be submitted via AJAX without reloading the page.

Continue reading »

CodeIgniter Tutorial Compilation

I write small CodeIgniter tutorial compilation, it’s not finished yet. Really like to have more feedbacks. Tweet me at http://twitter.com/komunitasweb
Thank you for your feedback.

Showing the weather with PHP and Google Weather API

weather

If you need to show weather in your website, you can use weather widget such as weatherbug. It’s nice and simple, but maybe you need something more integrated with your website. So, take a look at Google Weather API.

http://www.google.com/ig/api?weather=[city name]

Example :

http://www.google.com/ig/api?weather=jakarta

It will give you xml data, and you can parse it easy in PHP. Take a look at sample code.

Continue reading »

4 Simple PHP RSS Parser

Sometimes you need to parse RSS from other website and integrate to your project. Well you can create your own library to parse that RSS, but before wasting your development time, please take a look these great libraries for parsing RSS.

SimplePie

simplepie

SimplePie is a very fast and easy-to-use PHP class to parse RSS.

Features :

  • Single file, no install.
  • Cache mechanism.
  • Has plugin for such as WordPress, Joomla, Drupal and others.

Continue reading »

PHP Tips and Tricks

php

After years use PHP, there is always a time where I find myself look back to PHP documentation.

PHP has many functions, if you’re new to PHP, you won’t note some of useful function to remember.

There are also some of technique that you couldn’t learn by just looking PHP documentation.

For a beginner, who just learning basic PHP programming, I have collect some of tips and trick to help you upgrade your skill.

Continue reading »

CodeIgniter Tutorial – ORM with DataMapper

datamappertutorial

If you familiar with CodeIgniter, then you have realized by now that you can’t have relationship manager.

Yes, CodeIgniter doesn’t have built-in ORM. But there are several projects such as IgnitedRecord and DataMapper that will help you manage relationship between your models.

In this tutorial, I will introduce you to DataMapper.

From DataMapper Website

DataMapper is an Object Relational Mapper written in PHP for CodeIgniter. It is designed to map your Database tables into easy to work with objects, fully aware of the relationships between each other.

Features

  • Everything is an object!
  • Easy to setup, easy to use.
  • Custom Validation on object properties.
  • Lazy Loading (related objects are only loaded upon access).
  • Relations and their integrity are automatically managed for you.
  • One to One, One to Many, and Many to Many relations fully supported.\
  • Select data in the style of Active Record (with or without Method Chaining).

Ok let’s start our journey.

Continue reading »

CakePHP ACL Tutorial – What and How

CakePHP ACL

In this tutorials, I’ll show you everything you need to know to get started with CakePHP ACL. First you need to know what is ACL, and how ACL is implemented in CakePHP. Are you ready?

What

ACL or Access Control List is security concept about permission. It’s contain a list of permission to access some of resources. It specify who and what is allowed to access something.

In CakePHP ACL is used to specify users access to a controller, or specific action of a controller. Before we get to the how to section, there are a few terms we have to understand first.

  • Access Request Object (ARO) is defined who want to access or request object. In simple term, it will be a user or group. This list of user or group is stored in table called ‘aros’.
  • Access Control Object (ACO) is defined object that is being protected from a user or a group. In other word ACO related with which controller or action of controller you want to protect. ACO is stored in table called ‘acos’.

‘acos’ and ‘aros’ table is created automatically when you initialize the DB Acl tables (we’ll get into this later in how to part). Along with those table, there is table called ‘aros_acos’ which specify relationship between ARO and ACO. In english it will be mean which user has permission to a controller or action of controller.
Continue reading »

CodeIgniter Tutorials to Help You Get Started

Do you like CodeIgniter? Here a CodeIgniter round up collection to help you get started with this framework.

Introduction and Basic CodeIgniter Tutorial

  1. Introduction to Code Igniter: Part 1 – CodeIgniter introduction, get started with Model, View, and Controller in CodeIgniter
  2. Introduction to Code Igniter: Part 2 – Form and validation.
  3. Introduction to Code Igniter: Part 3 – Working with database.
  4. Everything You Need to Get Started With CodeIgniter – Introduction to CodeIgniter, installation and sample
    application.
  5. Building a Complete CodeIgniter Application: Part 1 - Installation and configuration.
  6. Building a Complete CodeIgniter Application: Part 2 – Feed parsing using SimplePie, unit testing and database.
  7. Building a Complete CodeIgniter Application: Part 3 -Handle security issue.

Basic

  1. Templating With CodeIgniter – Basic templating with CodeIgniter.
  2. Code Igniter Template Tutorial -Another template tutorial for CodeIgniter.
  3. Forms in CodeIgniter Views – Form tutorial in CodeIgniter.
  4. Pagination with Code Igniter – Build pagination system in CodeIgniter
  5. CodeIgniter: Interacting With a Database – Get close with database.

Need more advanced tutorials? Fine, we have here.
Continue reading »

101 PHP Tutorials for PHP Programmer Wannabe

When I type this, google for ‘php tutorial’ result 8,950,000 pages. Yes, there are tons of great tutorial about PHP. But when you’re a beginner, it will make you confuse what tutorials you should read. Either it’s too complicated or just waste your time.

So, here the shortcut. Take it and be a better PHP programmer by tomorrow. Hmm, maybe not that fast. But here they are.

WebMonkey

  1. PHP Tutorial for Beginners

PHP 101: PHP For the Absolute Beginner

  1. PHP 101 (part 1) Down the Rabbit Hole – An introduction to PHP’s variables and operators.
  2. PHP 101 (part 2) Calling All Operators – The rest of the PHP operators (there are many), and simple form processing.
  3. PHP 101 (part 3) Looping the Loop – Basic control structures explained.
  4. PHP 101 (part 4) The Food Factor – Arrays, PHP array functions, and what it all means.
  5. PHP 101 (part 5) Rank and File – Everything you’re ever likely to need to know about dealing with external files from a PHP script.
  6. PHP 101 (part 6) Functionally Yours – All about functions, arguments, passing by reference, globals and scope.
  7. PHP 101 (part 7) The Bear Necessities – A gentle introduction to object oriented programming in PHP 4 and PHP 5.
  8. PHP 101 (part 8) Databases and Other Animals – All about connecting to a MySQL database from PHP, using the mysql or mysqli extensions.
  9. PHP 101 (part 9) SQLite My Fire! – Introducing another database: SQLite.
  10. PHP 101 (part 10) A Session In The Cookie Jar – Sessions and cookies – how to keep track of visitors to your site.
  11. PHP 101 (part 11) Sinfully Simple – An introduction to PHP’s easiest method for dealing with XML.
  12. PHP 101 (part 12) Bugging Out – Basic error handling.
  13. PHP 101 (part 13) The Trashman Cometh – A primer in basic security.
  14. PHP 101 (part 14) Going to the Polls – Putting the pieces together – a first Web application.
  15. PHP 101 (part 15) No News is Good News – Creating a simple RSS news aggregator.

Continue reading »

CodeIgniter Tutorial – To do list application part 3

ci_logo_flame

Let’s take a look at our to do list application.

By now, you have familiarize your self with CodeIgniter framework. It is take a while to know everything, but if you keep learning then someday you will get there.

If you have completed last tutorial, then you have a to do list application based on CodeIgniter framework. It’s not complete, but at least working.

But if there is something you don’t understand, you could stop by, give a comment or ask me. Or maybe you want to correct me. That’s fine. We all learning here.

Let’s go build another features.
Continue reading »

10 Practical PHP Regular Expression Recipes

Latest update Email validation seems quite tricky. Do you have a better solution? Let’s have email validation challenge. And give the user the best way to validate an email format.

Mastering regex or regular expression is one advantages for you as programmer, but not everyone has time to learn something.

Not knowing how regex works doesn’t mean you couldn’t use the power of regex in your project.

Bookmark this list, so you can always going back here whenever you need this regex recipes.

Update :
Never though, my post will reach so many people, and cause so many reaction. But thank you to everyone, as I myself learn from my mistake.
Some credit goes to Joey Sochacki as I did use and modify some of his regular expression.

Continue reading »

20 Great PHP Libraries You Need to Know

You’re in the middle of a project, and need to get everything done as soon as possible. To keep the deadline and still have a life, you would better to collect this awesome library on your fingertip. By knowing this library capability, then you’ll know when to use any of them.

Charting Library

You can create simple graph or chart using GD library on PHP, but to help you create more complex chart, then you’ll need this awesome library.

  1. pChart – a PHP class to build charts.
  2. Libchart – Simple PHP chart drawing library.
  3. JpGraph – Object-oriented graph creating library for PHP.
  4. Open Flash Chart – Flash based charting library.

Continue reading »

CodeIgniter Tutorial – To do list application#2

ci_logo_flame

Let’s continue our journey with CodeIgniter, last time we built a simple to do list application. It is so simple and only have 1 feature, list your to do list.

But wait, right now we’ll add more power to this application. We will go step by step in this tutorial.

The to do list application are meaningless if we could not add new one. So let’s go upgrade it.

So, ready to open your favourite editor? Here we go.

Continue reading »

Codeigniter tutorial – To do list application

ci_logo_flame

What is CodeIgniter?

CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you’re a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you’re tired of ponderously large and thoroughly undocumented frameworks

CodeIgniter has an excellent documentation. It’s really help you in getting started. If you new to CodeIgniter, you can start by reading the user guide or read this excellent article Everything You Need to Get Started With CodeIgniter.

If you’re ready with your CodeIgniter, now we will create complete application using codeigniter. Building to do list in CodeIgniter. Let’s get started.
Continue reading »

Using Django template in PHP

How Django template work

In Django template you can’t mix programming logic into template, and this is by the design, because basically template is meant to express presentation. But of course, Django template provide something called tags which function similarly to some programming constructs. Now let’s go through some real example how Django template work.

In Django template we use {{ variable }} to express variable.

1
2
3
4
5
6
<html>
    <head><title>{{ page.title }}</title></head>
    <body>
        {{ page.body }}
    </body>
</html>

To loop over array or list we use for tag

1
2
3
4
5
6
7
8
9
<html>
    <head><title>{{ page.title }}</title></head>
    <body>
    {% for news in news_list %}
    <h2>{{ news.title }}</h2>
    <p>{{ news.content }}</p>
    {% endfor %} 
    </body>
</html>

And to simulate selection, Django template provide if tag

1
2
3
4
5
6
7
8
<html>
    <head><title>{{ page.title }}</title></head>
    <body>
    {% if message %}
    {{ message }}
    {% endif %}
    </body>
</html>

Continue reading »

PHP : Masking image with GD

My friend : Is it possible to use PHP and GD for croping image not in rectangle?

Me : Hmm, well so far I just play with GD only for creating thumbnail or crop an image. What exactly do you mean by that?

My friend : I need to crop an image and need the result in ellipse, so there will be an ellipse showing part of the image, and outside that ellipse should be transparent.

Me : What do you need that for?

My friend : Hmm, well just for some project I’m currently handle.

Me : I promise you nothing, but I’ll give it a shoot. Continue reading »

Getting started with XML/SWF Charts

Requirement

  • web browser with Flash Player 9 or later
  • XML/SWF Charts

Installation

  1. Download XML/SWF Charts, extract the download package, and put somewhere on your web server. I put mine into folder charts.
  2. Open your browser, and go to http://localhost/charts/sample.html

Continue reading »

CakePHP Tutorial:Installing CakePHP on Ubuntu

Yes, this is another cakephp on ubuntu. Most of them were not detail enough for beginners. So here I am and here is my version of installing cakephp on ubuntu. Continue reading »