Jump to content

Setting class paths


Xu Wei Jie

Recommended Posts

The only way you can do this is place all your classes within a dedicated folder. You'll then want to add this folder to PHP's include_path setting. So when

ever you want to include a class you'd do

 

include 'your_class.php';

 

rather than

include 'path/to/your_class.php';

Link to comment
Share on other sites

I think both of you are mistaken. I wanted to put all my written scripts into a library(folder) and set the classpath to them so I would not need to type out long paths to execute them. ( for example the php command, once it is installed and having its class path set, you can invoke it from any directory). I do want to achieve that effect.

 

i.e php x.php

 

x.php is stored in a library I created. i wish to invoke it from any directory, is it possible?

 

 

Link to comment
Share on other sites

Your question has nothing to do with php itself. Its your shell that parses the command

 

php x.php

 

And no, x.php will need to be within the current directory or you will need to give your shell the complete path to the file.

Link to comment
Share on other sites

Your going to struggle there. Windows won't recognise a shabang and only has a very limited shell (if you could even call it that).

 

If this is the only entry point to your application you could likey write a wrapper around it specific to the OS its running on. But again, this isn't a php question.

Link to comment
Share on other sites

On Windows, you will need to edit the System Environmental variables to include the folder with your PHP executable as well as your 'library'

 

Unix based platforms are the same concept, but a little different in execution

 

edit: actually...since the path to the script would be an argument to the PHP executable, this won't work...hum....

Link to comment
Share on other sites

Edit:  I think I may have entirely misunderstood this thread....  If so, just ignore this.

 

 

 

You can set the handler for .php files, just as the handler is set for .bat, .jpg... so on.

 

 

All you have to do is associate the .php file extension with your PHP binary.

 

 

Don't remember the exact steps to do it through the registry, but you should be able to do it through the Open With menu when right clicking.

 

 

Then, after .php is associated with it, you should be able to just do:

 

 

file.php in the command line.

Link to comment
Share on other sites

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.