1

I have a directory of PHP scripts ( mainly utilities), that is located on C:\Development, whereas my Symfony application is located in D:\Development.

How to include the utility scripts into the Symfony application? I try not to use include() because I prefer a symfony-like command.

2 Answers 2

2

There are basically two approaches

  1. Extend the autoloading
  2. modify the include path

#2 can be achieved numerous ways. If you are unsure how to, let me know and I'll post some details.

You don't have to change php.ini. You can use ini_set or set_include_path. Check ricardo's comment in the User Contributed Notes section at the documentation for set_include_path().

Sign up to request clarification or add additional context in comments.

3 Comments

Modify the include path.. are you saying that I have to change the PHP.ini file? I don't prefer that; instead, I would like do the referencing inside my Symfony application
I modified my answer to address your comment
+1 The autoload extension is the way to do it whilst staying within Symfony.
2

Personally, I'd create a new folder inside the lib/vendor folder on your project, put your scripts in there, and then symfony should handle it all automatically assuming you've followed its naming conventions for files/classes. If not, you may need to alter the autoload stuff as per Peter Bailey's answer.

I prefer this way because I like to be able to deploy the project from one server to another as one atomic unit with no reliance on external dependancies. This may not be an issue for you though, in which case the existing answer will suit you better.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.