如何使用安装了不支持自动加载的作曲器的库?例句:
<?php
class ColorGenerator
{
public function foo()
{
$color = new Color("#336699");
//Class 'Color' not found
$color = new phpColors'Color("#336699");
//Class 'phpColors'Color' not found
}
}
我假定需要类文件,但我不知道最佳实践解决方案是什么。
从你的链接:
/**
* Using The Class
*/
use phpColors'Color;
// Initialize my color
$myBlue = new Color("#336699");
echo $myBlue->darken();
// 1a334d
第一行代码看起来你可能会感兴趣…只要确保你有源代码(phpColors文件夹)在同一目录下的。php文件,你试图使用它在。
EDIT: Changed using
to use
。