Mathew Byrne
Mathew Byrne

Reputation: 3759

Autloading classes from Symfony Task

I'm working with a Symfony 1.1 code-base and attempting to write a plugin containing a task that will automate some processes.

Currently I'm finding that inside the Task, Symfony does not completely bootstrap class autoloading. It seems to register the sfCoreAutoload class but I'm unable to autoload other classes from the same plugin, or from any other plugins.

Directory structure resembles:

/project
  /plugin
    /myPlugin
      /lib
        /class
          myClass.class.php
        /task
          myTask.class.php

The Task loads fine but in this setup is unable to autoload myClass. Usually I would just require the file, but myClass depends on another plugin being available.

It seems confusing that the Symfony CLI wouldn't register autoloading for the rest of the application you're currently running, similar to how it would for a web app.

Upvotes: 1

Views: 654

Answers (1)

Jeremy Kauffman
Jeremy Kauffman

Reputation: 10413

You've run into one of several annoying aspects of Symfony tasks.

If you can put whatever you're doing in execute instead of configure, you should be alright. I believe every task's configure method is called on every task execution, so you don't want anything heavy in there anyway.

Upvotes: 1

Related Questions