freelanceprogrammers.org Forum Index » PHP
Re: Smarty Installation
Joined: 03 May 2005
Posts: 10
Re: Smarty Installation
i have installed on Linux. so I am sending you some steps. You follow it.
Ater complete your step you will get smarty.
girija
you read it and follow.
Installation
This MVC architecture can be implemented in PHP using the `Smarty` Template
engine.
Follow the simple steps to implement MVC in PHP on Linux system.
Its assumed that PHP 4.3 > and Apache Web server are installed properly.
Step 1:
-------
Download `Smarty` from http://smarty.php.net/download.php,unzip/untar the
downloaded file then copy the folder "libs" from the extracted files to the
webfolder of your webserver (or upload it to
the docroot of the remote webserver if you are using hosting your site through a
web service provider)
Example:
--------
On Red Hat Linux systems generally the webfolder can be found at /var/www/,so
copy libs folder this location as follows
#cp -fr libs /var/www/
Step 2:
-------
Rename the copied folder (libs) as `smarty`.
Step 3:
-------
Create a folder in your docroot i.e /var/www/html , we will name that folder as
`smarty-rocks`!
Step 4:
-------
Under `smarty-rocks` create two subfolders called `html` and `compile`.
Step 5:
-------
If yours is an Unix distribution then give all privileges to `compile` folder.
#chmod 777 compile
Step 6:
-------
Now in `smarty-rocks` folder create the following file and save it as
"libs.inc.php "
-------
***********************************************
<?php
$fixpath = dirname(__FILE__);
define ("SMARTY_DIR","/var/www/smarty/"); /* location of the `smarty folder */
require_once (SMARTY_DIR."Smarty.class.php");
$smarty = new Smarty;
$smarty->compile_dir = "$fixpath/compile";
$smarty->template_dir = "$fixpath/html";
?>
************************************************
Step: 7
-------
Now its time to get into actual action! Create another file with the following
content under /var/www/html/smarty-rocks/ and save it as `smarty1.php`
***********************************
<?php
require_once ("./libs.inc.php");
$smarty->assign ("firstname","Vikram");
$smarty->assign ("lastlogin",date("l he jS"));
$smarty->display ("example4.html");
?>
In the above program we are assigning value "Vikram" to the smarty variable
"firstname",similarly assigning the current date to the smarty variable
"lastlogin" and finally invoking the smarty command to display the relevant page
( u will understand the above code when you execute the next step)
Step: 8
-------
Create the following file under /var/www/smarty-rocks/html/ and save it as
`smarty1.html`
Hi {$firstname} your lastlogin date was {$lastlogin}.
</body>
</html>
*******************************
In the above html code we are invoking the `smarty` variables
(firstname,lastlogin...defined in smarty1.php).
Step: 9
--------
Now from the browser run the following file to see the output..
http://localhost/smarty-rocks/smarty1.php (if local system)
or
http://<your website>/smarty-rocks/smarty1.php (If using remote webserver)
You might have noticed how we seperated the design code from the actual
application logic by creating to seperate files (smarty1.html,smarty1.php).
The above tutorial is a very good starting point into the world of MVC
programming !!For further understanding the concepts go through the
Documentation that comes along with the `smarty` download.
Hope the above tutorial helped in understanding howto implement MVC arhitecture
in PHP using Smarty Template engine.
On Thu, 22 Sep 2005 Vandan C.Desai wrote :
>Hi
>I am new to Smarty... i am using Windows XP with Apache 2 running on my system.
I have PHP4.4.0 version. I downloaded the smart and unzipped it and placed it in
the htdocs folder under apache. and also wrote the include_path in the php.ini
file. Still the smarty does not work. can anyone help me out with this
>
>Regards
>Vandan
>
>
>Vandan C. Desai
>Software Engineer
>Stylus Systems Pvt. Ltd.
>"COMPUTERS are Useless. The can only give you ANSWERS"
>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam? Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com
>
>[Non-text portions of this message have been removed]
>
>
>
>
>PHP Data object relational mapping generator - http://www.meta-language.net/
>Yahoo! Groups Links
>
>
>
>
>
>
[Non-text portions of this message have been removed]
Joined: 03 May 2005
Posts: 10
Re: Smarty Installation
Any body know installation of Mod_perl on Linux.
Please give me steps.
giriaj
On Thu, 22 Sep 2005 Vandan C.Desai wrote :
>Hi
>I am new to Smarty... i am using Windows XP with Apache 2 running on my system.
I have PHP4.4.0 version. I downloaded the smart and unzipped it and placed it in
the htdocs folder under apache. and also wrote the include_path in the php.ini
file. Still the smarty does not work. can anyone help me out with this
>
>Regards
>Vandan
>
>
>Vandan C. Desai
>Software Engineer
>Stylus Systems Pvt. Ltd.
>"COMPUTERS are Useless. The can only give you ANSWERS"
>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam? Yahoo! Mail has the best spam protection around
>http://mail.yahoo.com
>
>[Non-text portions of this message have been removed]
>
>
>
>
>PHP Data object relational mapping generator - http://www.meta-language.net/
>Yahoo! Groups Links
>
>
>
>
>
>
[Non-text portions of this message have been removed]
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







