Jump to content

Installing Smarty When I Can't Modify php.ini


Vermillion

Recommended Posts

First, I hope I got the right forum...

 

I use [http://www.07x.net 07x] (which sucks btw, but can't find anything better) as my host.

I want to install Smarty because it seems like that thing owns when it comes to separate HTML from PHP.

 

I have found [http://news.php.net/php.smarty.dev/2703 this guide] (well, Huntyr linked me to it ;P), and the main problem is that I can't modify the php.ini file to add a new includes location. I know I could change the installation guide a bit, but I heard that keeping the Smarty files out of the htdocs/www folder is safer.

 

If anyone has a possible solution, I will highly appreciate it ._..

Link to comment
Share on other sites

You can set your include path by using ini_set() prior to everything else.  This works best if done in an include file that is always loaded first.

 

ini_set('include_path', ini_get('include_path') . ':'/path/to/the/additional/path/');

 

And since you mentioned it Hostmysite.com has some pretty awesome hosting.

Link to comment
Share on other sites

Opps sorry looks like there is a syntax error in mine.

 

Here is mine correct.

ini_set('include_path', ini_get('include_path') . ':/path/to/the/additional/path/');

 

 

thorpe's is better though.  I forgot about the php functions for set_include_path() and get_include_path().  This is a cleaner way. 

 

And yes the absolute path does not have to be in your web root. Specify it from the servers root. 

 

What you want to do is create a config file for your application that always gets run first.  Just put this in that config file then include that file at the top of all outward facing files. Never duplicate code. Write it once and reuse it.

 

Link to comment
Share on other sites

Will set_include_path() modify the php.ini file?

I used get_include_path(), and I don't know where I will find this:

 

.:/usr/share/php:/tmp

 

lol

 

No, it won't modify your php.ini. It simply sets your include_path at runtime. The reason we use get_include_path inside the call to set_include_path is so that we can add to the current path. Your path is a list of directories seperated by :

 

So, your current path contains threee directories.

 

. <- the directory your script executes from.

/usr/share/php <- a common php include. This is where things like PEAR, Zend Framework and Smarty are usually installed.

/tmp <- The systems temporary directory.

Link to comment
Share on other sites

Inside the "php" directory, I have the htdocs directory, right? I can't check all the directories since I am on FTP to upload the files, I can just the directory that keeps htdocs inside.

 

No, if your on a shared server your htdocs directory is normally within your home directory somewhere. Something like /home/username/htdocs. /usr/share/php is (as I said in my previous reply) normally where shared libraries (like zend framework, pear and even smarty) are installed. On a shared host you won't have control over whats in /usr/share/php but you can use whatever is in there becuasde its in your include path.

Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.