a

mkaknakdnaknaknakfnakafafafaf

Sabtu, 15 September 2012

CodeIgniter: Installation


CodeIgniter is installed in four steps:
  1. Unzip the package.
  2. Upload the CodeIgniter folders and files to your server. Normally the index.php file will be at your root.
  3. Open the application/config/config.php file with a text editor and set your base URL. If you intend to use encryption or sessions, set your encryption key.
  4. If you intend to use a database, open the application/config/database.php file with a text editor and set your database settings.
If you wish to increase security by hiding the location of your CodeIgniter files you can rename the system and application folders to something more private. If you do rename them, you must open your main index.php file and set the $system_folder and$application_folder variables at the top of the file with the new name you've chosen.
For the best security, both the system and any application folders should be placed above web root so that they are not directly accessible via a browser. By default, .htaccess files are included in each folder to help prevent direct access, but it is best to remove them from public access entirely in case the web server configuration changes or doesn't abide by the .htaccess.
After moving them, open your main index.php file and set the $system_folder and $application_folder variables, preferably with a full path, e.g. '/www/MyUser/system'.
One additional measure to take in production environments is to disable PHP error reporting and any other development-only functionality. In CodeIgniter, this can be done by setting the ENVIRONMENT constant, which is more fully described on the security page.
That's it!
If you're new to CodeIgniter, please read the Getting Started section of the User Guide to begin learning how to build dynamic PHP applications. Enjoy!

What is CodeIgniter?


CodeIgniter is a free, open-source, easy-to-use, object-oriented PHP web application framework, providing a ready-to-use library to use with your own PHP applications. For example, there is a Database API to make it easier and more convenient to execute SQL queries, such as SELECT, UPDATE, DELETE, INSERT, etc., without having to create a lot of repetitive code yourself. This is how an application framework is useful in application development.
CodeIgniter is object-oriented

Using CodeIgniter requiring knowledge of using the object-oriented programming technique in order to be able to use CodeIgniter effectively, and to understand what happens when you are using certain features in CodeIgniter.

But, what is object-oriented programming?
It’s quite difficult to explain object-oriented programming because from a conceptual point of view, it is difficult to understand. However, the main purpose of object-oriented programming is to make application development easier, especially as applications become bigger, with large structures. Object-oriented programming allows application code and logic to be easier to understand, structured and coherently in place, making it easier to develop and extend your application’s features and functionality. With procedural programming (which is merely standard code executed line-by-line with the use of functions as a container for code that help prevent repetitiveness and “reinventing the wheel”), applications can become a mess if they aren’t developed in a way where everything is well laid out, coherent and structured, and can be more difficult to extend and add new features and functionality to your applications later on. With object-oriented programming, in a way, you are forced to be coherent and have your code structured correctly.
Classes and Methods
What are classes and methods? These are the first concepts you’ll be introduced to if you are learning object-oriented programming from most books or online resources. Say you’re creating a framework. You’ll have different classes for different parts of your framework. One being a “Database Class”, one being an “E-mail Class”, and so forth. Of course, in this case, the Database Class is like the CodeIgniter Database Class, providing a set of ready-made methods for you to use so you don’t have to create them yourself in order to execute certain application logic, such as inserting, updating and removing database records quickly, without having to “reinvent the wheel”.
The methods are what contain the application logic, and the class merely holds many related methods together. And this is exactly how your applications would work with the use of the object-oriented programming techniques.
How does CodeIgniter work?
CodeIgniter has a very extensive user guide, which is much better than documentation on some other frameworks, such as CakePHP (which is another PHP framework).
CodeIgniter has classes and helpers.
Classes
Classes contain a collection of methods and properties (properties are essentially variables in an object-oriented context).
For example, here is an example using the Database library within CodeIgniter:
$this->db->get(‘users’,$data);
In any application you make using CodeIgniter, your own classes inherit (or extends) the CodeIgniter class, and so this is why the $this variable is used, which refers to the current class/object. So to call another method within your class, you would use$this->method_name().
Helpers
Helpers contain ordinary PHP functions. Such as the Form Helper.
Other interesting features of CodeIgniter
While this is by no means unique to CodeIgniter, and other web application frameworks use this approach to application development, CodeIgniter primarily uses the Model, View, Controller (MVC) approach to application design and development. It essentially separates application logic from the application design/view. The application logic is the Controller, whereas the application design/view is the View. The Model is for database interactions. There are more complex scenarios where the MVC approach is used, but for basic to intermediate CodeIgniter applications, the Model would contain database interactivity logic of sorts.
Active Record
When you saw an example of using the Database Class above, that code is actually part of the Active Record Class that is part of the Database library.
Active Record is where your work can be shortened by providing an easy and convenient way to execute certain SQL queries without having to write out the entire SQL query yourself. Active Record essentially allows information to be updated, retrieved, added and removed conveniently.
More information on CodeIgniter
The CodeIgniter framework works on all of our shared and reseller servers, and can be installed on pretty much any server with PHP installed. As of writing, CodeIgniter requires PHP version 5.1.6 or higher and obviously a database will be required for any database-driven PHP application (as of writing, MySQL 4.1 or higher). CodeIgniter also supports PostgreSQL, Oracle, SQLite and ODBC. For up to date server requirements, see the CodeIgniter user guide.

Kamis, 13 September 2012

What is PHP


Whenever anyone is learning PHP, the most common questions that first come up are: What is PHP? And how does it work?
It is precisely these questions we will look at in this lesson. It's a big help to understand such basics related to PHP before you start developing you own PHP pages. Such basic understanding will increase the speed of learning significantly.
So, let's get started!

What is PHP?
PHP was originally an acronym for Personal Home Pages, but is now a recursive acronym forPHP: Hypertext Preprocessor.
PHP was originally developed by the Danish Greenlander Rasmus Lerdorf, and was subsequently developed as open source. PHP is not a proper web standard - but an open-source technology. PHP is neither real programming language - but PHP lets you use so-called scripting in your documents.
To describe what a PHP page is, you could say that it is a file with the extension .php that contains a combination of HTML tags and scripts that run on a web server.

How does PHP work?
The best way to explain how PHP works is by comparing it with standard HTML. Imagine you type the address of an HTML document (e.g. http://www.mysite.com/page.htm) in the address line of the browser. This way you request an HTML page. It could be illustrated like this:
The figure shows a client that requests an HTML file from a server
As you can see, the server simply sends an HTML file to the client. But if you instead typehttp://www.mysite.com/page.php - and thus request an PHP page - the server is put to work:
The figure shows a client that requests a PHP file from a server
The server first reads the PHP file carefully to see if there are any tasks that need to be executed. Only when the server has done what it is supposed to do, the result is then sent to the client. It is important to understand that the client only sees the result of the server's work, not the actual instructions.
This means that if you click "view source" on a PHP page, you do not see the PHP codes - only basic HTML tags. Therefore, you cannot see how a PHP page is made by using "view source". You have to learn PHP in other ways, for example, by reading this tutorial.

What you learn in this tutorial is to write commands to a server!
So, the first thing you need to get ahold of is... a server! But don't worry - you don't need to buy a new computer. You just need to install some software on your computer that makes it function as a server. Another option is to have a website on a hosted server that supports PHP. Then you just need to be online while coding.