在cakephp 4.2中访问模型中的模型时,docs命令FactoryLocator不起作用。
Class 'App\Model\Table\FactoryLocator' not found
use Cake\ORM\TableLocator; //tried this
use Cake\Datasource\Locator\LocatorInterface; //tried this
class LessonsTable extends Table
public function getTest1(){
$clients = FactoryLocator::get('Table')->get('Clients'); //error here
https://book.cakephp.org/4/en/orm/table-objects.html#using-the-tablelocator
https://api.cakephp.org/4.1/class-Cake.Datasource.FactoryLocator.html
1条答案
按热度按时间cngwdvgl1#
再次;)
我不知道你用哪个编辑器写php代码,但我建议你使用插件,它会提示在当前的php文件中哪些php / cakephp方法可用。
例如,在https://code.visualstudio.com/中添加一些扩展名,如
https://marketplace.visualstudio.com/search?term=php&target=VSCode&category=All%20categories&sortBy=Relevance
对于代码完成,请使用https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client
然后当你键入
FactoryLo
时,编辑器会找到类/方法并向你建议,如果缺少命名空间,它也会自动添加。