NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Cannot use Smarty


Joined: 01 Jan 2013
Posts: 3
Reply with quote
I created the example in "http://www.nusphere.com/php/templates_smarty.htm" but I am getting error messages:
Warning: include(Smarty.class.php): failed to open stream: No such file or directory in C:\wamp\www\page1.php on line 2

Warning: include(): Failed opening 'Smarty.class.php' for inclusion (include_path='.;C:\Program Files (x86)\NuSphere\PhpED\php54\..\include_lib') in C:\wamp\www\page1.php on line 2

Fatal error: Class 'Smarty' not found in C:\wamp\www\page1.php on line 3

Do I have to install Smarty? How?

Your answer will be greatly appreciated.
View user's profileFind all posts by handro1104Send private messageSend e-mail
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
Smarty is a PHP based template engine. Whilst PhpED understands Smarty templates, you do have to copy the Smarty engine files into your site so that you can then call Smarty and have your templates processed. Visit http://www.smarty.net/ to download Smarty & find out more about it and http://www.smarty.net/crash_course for a quick introduction.
View user's profileFind all posts by plugnplaySend private message


Joined: 01 Jan 2013
Posts: 3
Reply with quote
Thank you very much for your prompt answer. I have Smarty and I have installed it into wampp and xamp. Can you tell me how to install it in PhpED? should I just copy the contents into a smarty directory? what else?
View user's profileFind all posts by handro1104Send private messageSend e-mail
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
You do not install it in PhpED. You copy it into the web site then PhpED will pickup the classes, etc. for code completion. PhpED has built-in support for understanding Smarty syntax within tpl files and does not require Smarty to be installed for editing/development to work. The site does require Smarty to be installed for the site to work.

If you have copied it into the smarty folder in the web site then your include statement might be:

Code:
include('smarty/Smarty.class.php');


If you do not specify the path for the file being included, then the include_path is used to locate the file first, before looking in the current directory. The warning you are seeing appears to be because PHP cannot find Smarty.class.php in the include_path.

If you are planning on transferring your web site on another server, having Smarty within a subdirectory of your site is probably best because then you are in control of what version of Smarty is used and your site is then self-contained.

So to get started I would recommend:

1. Ensure Smarty is installed in a smarty subdirectory of your site
2. Change the include statement to what I've shown above so that it refers to the smarty subdirectory
View user's profileFind all posts by plugnplaySend private message


Joined: 01 Jan 2013
Posts: 3
Reply with quote
Thanks again. For some reason I had not set Smarty in wamp; it is working fine with Eclipse. But I am still having a problem with PhpED. I am trying to set up a project with wamp and I created the project with web root C:wamp/www, but I am getting the error:
please check your firewall settings and make sure that PhpED.exe is allowed to connect to the web server, web server is allowed to be connected and it is running.
I allowed PhpED.exe to go throuh the firewal, but I don't know how to allow the web server; should I enable ApacheMonitor.exe or httpd.exe in C:\wamp\bin\apache\apache2.2.22\bin? I don't see ApacheMonitor.exe or httpd.exe in the task manager.
[/img]
View user's profileFind all posts by handro1104Send private messageSend e-mail
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
How many web servers do you have running? httpd.exe is the Apache service, which I normally turn on/off either from a command prompt or Windows services manager. If it is using port 80 then I don't remember having to change firewall settings for it before. PhpED communicates with the PHP DBG Listener, which then communicates with the debugger (DBG) normally using port 7869 and that port would have to be opened on a firewall.

If you are having a variety of issues, work on one at a time. Getting the web site running (forget PhpED for now) would be good maybe using a simple hello world page, then you can implement PhpED and the debugger.

For developing projects I highly recommend not using localhost as a domain name and I'm guessing you are because you are using c:\wamp\www as a project root. Have a look at Apache virtual hosts and give each site/project its own root under C:\wamp\www. There are a variety of benefits to this, such as keeping cookies separate to each site. Also some PHP code/frameworks do not like localhost as a domain name, because it is normally used without any dots which is technically invalid.

Use domain name such as mysite.local (eg virtual host directory c:\wamp\www\mysite) and mysite2.local (eg virtual host directory c:\wamp\www\mysite2). You can use your Windows hosts file to setup those domain names to point to 127.0.0.1 and the Apache httpd-vhosts.conf to point the domain names to the correct directories.
View user's profileFind all posts by plugnplaySend private message
Cannot use smarty on build-in srv webserver


Joined: 22 Apr 2014
Posts: 6
Reply with quote
Sorry to resurrect an old thread, however it seems better than starting a new one.

I too am also unable to use smarty.

According to this page: http://www.nusphere.com/php/templates_smarty.htm

PHPed automatically installs smarty.

Also, you can see the tutorial shows you simply create the 2 files, and execute them.

So the question really is: How to make the srv.exe web server recognize smarty?

And why is it not automatically installed as indicated on the website?

Thank you!
View user's profileFind all posts by themrrobertSend private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
PhpED recognises smarty syntax in the editor; you can edit smarty templates.

You also have to install smarty support in your web application, because it is a PHP library. Your web application must call smarty to process the templates. Some web applications will use different versions of smarty. Some existing web applications will come with smarty.

Visit http://www.smarty.net/download to download it, where you will find the latest stable version plus older releases. Visit http://www.smarty.net/quick_install for an install guide and also how an example of how to configure smarty into your own application.

I've just read the page at http://www.nusphere.com/php/templates_smarty.htm and despite what it says, I don't think PhpED does install smarty. It certainly hasn't ever automatically installed it in in my Apache web servers and I would hope not, because I would be annoyed if it did install anything like that in my web servers.

Maybe they were referring to SRV, but smarty isn't installed in there either.

Anyway, get your own direct from smarty then you will have the latest and greatest Smile
View user's profileFind all posts by plugnplaySend private message
Cannot use Smarty
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
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic