开发者

Autloading classes from Symfony Task

开发者 https://www.devze.com 2023-03-24 05:55 出处:网络
I\'m working with a Symfony 1.1 code-base and attempting to write a plugin containing a task that will aut开发者_运维问答omate some processes.

I'm working with a Symfony 1.1 code-base and attempting to write a plugin containing a task that will aut开发者_运维问答omate 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消