2

so, I have some php files in my apps/myprogram/lib folder. e.g. apps/myprogram/lib/myLibA.class.php

When I run in my modules/actions/ scripts, and try to use the functions in myLibA, I cannot. because symfony complains that the myLibA class is not defined.

do I need to specify anywhere in the symfony framework that myLibA.class.php is a required library?

2 Answers 2

6

Symfony's autoloader looks by default for your classes in the top-level <project>/lib directory. Any file in that directory or below (with the exception of "vendor") will be searched for classes. Symfony searches for any .php file with class declarations and adds them to the autoload system.

Additionally, you can add search paths in your application's autoload.yml file. For example, for one of my applications I've put a third-party Flickr library in <project>/vendor/phpFlickr, and my <project>/apps/frontend/config/autoload.yml file looks like:

autoload:
    vendor_php_flickr:
        path: %SF_LIB_DIR%/vendor/phpFlickr
        recursive: on

That allows all classes below .../vendor/phpFlickr to be autoloaded.

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

Comments

0

this is an alternative way, you can define/add to your preExecute this:

public function preExecute()
{
  $this->getContext()->getConfiguration()->loadHelpers('Foo', 'Bar');
}

taken from (http://oldforum.symfony-project.org/index.php/m/92916/)

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.