English 中文(简体)
• 如何用假冒装一个班子?
原标题:How to load a class in symfony?

我需要装上表象1.4的一类,但将档案放在/apps/frontend/lib上。 似乎还不够。

class test
{ function foo ($foo) { echo $foo; }
}

我试图在行动中加以利用:

  public function executeTest(sfWebRequest $request)
  {
    $a = new test();
    $a->foo( aaa );
  }  

我已经更新了藏匿点,至今:

<编码> 致命错误: ......未找到的班级测试

我是否必须宣布这一点?

最佳回答

您的档案必须贴在您的项目中:

我的项目/安排

[Updating] About loading a class from a file in myproject/apps/frontend/lib/ maybe the problem is the filename where is the class. I found in this page A Gentle Introduction to symfony - Chapter 2 - Exploring Symfony s Code that:

Symfony will then look for a MyClass definition in all files ending with class.php in one of the project s lib/ directories. If the class definition is found, it will be included automatically.

So if you store all your classes in lib/ directories, you don t need to include classes anymore. That s why symfony projects usually do not contain any include_once or require_once statements.

问题回答

与其他答复相反,在<代码>/apps/frontend/lib/上的班次绝对 如在<条码>上载,应由自动载荷装载。

另有一些事情正在继续。 贵国的类别是否实际被点名? 如果你重新生产,你是否清除了你的海滩?





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签