<html>
<head>
<title></title>
</head>
<body>
<div style=" width :700px; height; 500px; -moz-border-radius: 10px; -webkit-border-radius: 5px; border: 1px solid #eeeeee; padding: 10px;">
</div>
</body>
</html>
Tuesday, September 7, 2010
Monday, September 6, 2010
Installing CakePHP on Ubuntu
CakePHP is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. Using commonly known design patterns like MVC and ORM within the convention over configuration paradigm, CakePHP reduces development costs and helps developers write less code.
Installation is actually quite an easy task. But I couldn’t find good information at the beginning. So here I am writing for you. I am using Ubuntu 9.10. This will work for any *nix systems.
sudo apt-get install apache2 mysql-server php5
I am using 1.2 version of cakephp
sudo chmod -R 777 cakephp/app/tmp
sudo a2enmod rewrite
sudo vi /etc/apache2/sites-enabled/000-default
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Configure::write(‘Security.salt’, ‘DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi’);
Just change the value of it.I have come up with this value
Configure::write(‘Security.salt’, ‘UubWwvniR2G0FgaC9miDYhG93b0qyJfIxfs2guVo’);
change the file name to database.php
sudo mv database.php.default database.php
Then edit the following
sudo vi cakephp/app/config/database.php
You can connect to any database you want. Make sure that username and password of your database are correct.
sudo /etc/init.d/apache2 restart
Installation is actually quite an easy task. But I couldn’t find good information at the beginning. So here I am writing for you. I am using Ubuntu 9.10. This will work for any *nix systems.
Step 1:
In order to work with cakephp you need to have Apache server , MySql Database and PHP. To get themsudo apt-get install apache2 mysql-server php5
Step 2:
Download the Latest version or the stable version of Cakephp. You can get it from here downloadI am using 1.2 version of cakephp
Step 3:
Copy and Extract the compressed file to the webroot(/var/www) and rename to cakephp or some project_name. Open http://localhost/cakephp in your browser. You will see something like this.Step 4:
Enable write permission for app/tempsudo chmod -R 777 cakephp/app/tmp
Step 5:
Enable mod_rewrite. More about mod_rewrite here.sudo a2enmod rewrite
Step 6:
Edit the file /etc/apache2/sites-enabled/000-default and change AllowOverride None to AllowOverride All. You can use any text editor. I am using vi editor.sudo vi /etc/apache2/sites-enabled/000-default
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Step 7:
Changing the value of security.salt in app/config/core.php. At line 151 or near to it you can see something like thisConfigure::write(‘Security.salt’, ‘DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi’);
Just change the value of it.I have come up with this value
Configure::write(‘Security.salt’, ‘UubWwvniR2G0FgaC9miDYhG93b0qyJfIxfs2guVo’);
Step 8:
Database Configuration. The database configuration file is located at cakephp/app/config/database.php.defaultchange the file name to database.php
sudo mv database.php.default database.php
Then edit the following
sudo vi cakephp/app/config/database.php
class DATABASE_CONFIG {
var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => 'sudeep',
'database' => 'cakephp',
'prefix' => '',
);
You can connect to any database you want. Make sure that username and password of your database are correct.
Step 9:
Restart Apache server to see changessudo /etc/init.d/apache2 restart
Step 10:
Open http://localhost/cakephp/ in your browser.If all goes well you should be able to cakephp page in colors, something like this.Ajax Example
<html>
<head>
<title></title>
<script type="text/javascript">
if(window.ActiveXObject)
{
xmlhttp = new ActiveXObeject("MSxml2.XMLHTTP");
}
else if(window.ActiveXObject)
{
xmlhttp = new ActiveXObeject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
function loadXMLDoc()
{
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 )
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","/ajax_info.php",true);
xmlhttp.send(null);
}
</script>
</head>
<body>
<div id="myDiv"><p>Ajax comes here<p>
</div>
<input type="submit" value="Click" name="submit" onclick="loadXMLDoc()">
</body>
</html>
Explanation: First u have check that,if the browser supports ajax or not , for that there is the code above ,which is inside the script tag and then create a function with loadXMLDoc() ,
1.when the user clicks on submit button the function gets called 2.onreadystatechange is typical the event handler that triggers or call the javascript function , and it fires at every state change
3. readystate --- > it is the state request , set equal to 4 means that the request and response is loaded asynchronously from server and it is complete
4 .There are 0,1,2,3, 0-> unintialized
1-->loading
2---> loaded
3--> interactive
4---> complete
create a a file called ajax_info.php ,in the just echo something so that the user clicks the submit button the ajax_info .php file is loaded under the div part without a page refresh , Here GET is the request , where we r getting the information , and t should be true because the data is transforming asynchronously.
<head>
<title></title>
<script type="text/javascript">
if(window.ActiveXObject)
{
xmlhttp = new ActiveXObeject("MSxml2.XMLHTTP");
}
else if(window.ActiveXObject)
{
xmlhttp = new ActiveXObeject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
function loadXMLDoc()
{
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 )
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","/ajax_info.php",true);
xmlhttp.send(null);
}
</script>
</head>
<body>
<div id="myDiv"><p>Ajax comes here<p>
</div>
<input type="submit" value="Click" name="submit" onclick="loadXMLDoc()">
</body>
</html>
Explanation: First u have check that,if the browser supports ajax or not , for that there is the code above ,which is inside the script tag and then create a function with loadXMLDoc() ,
1.when the user clicks on submit button the function gets called 2.onreadystatechange is typical the event handler that triggers or call the javascript function , and it fires at every state change
3. readystate --- > it is the state request , set equal to 4 means that the request and response is loaded asynchronously from server and it is complete
4 .There are 0,1,2,3, 0-> unintialized
1-->loading
2---> loaded
3--> interactive
4---> complete
create a a file called ajax_info.php ,in the just echo something so that the user clicks the submit button the ajax_info .php file is loaded under the div part without a page refresh , Here GET is the request , where we r getting the information , and t should be true because the data is transforming asynchronously.
Subscribe to:
Posts (Atom)