I am using notepad++. I have installed composer and from command line I have tried to install the php-ai/php-ml using the following line of code composer require php-ai/php-ml
. My cmd tells me that this is successfully installed and everything seems okay.
However, in my index.php file if I try to use any of the libraries in the package php-ai/php-ml for example: use Phpml\\Dataset\\CsvDataset;
I get the following error:
Fatal error: Uncaught Error: Class 'Phpml\\Dataset\\CsvDataset' not found in C:\\xampp\\htdocs\\test\\index.php:5 Stack trace: #0 {main} thrown in C:\\xampp\\htdocs\\test\\index.php on line 5
Line 5 is the line which i request to use the library. Do i have to import these libraries or anything?
Composer files are dependecies for the project, so what you should do is:
require __DIR__ . '/vendor/autoload.php'
require __DIR__ . '/vendor/autoload.php'
in the top of your index.php Have you required the vendor/autoload.php file first in your script? This is required to auto load the classes from composer.
<?php
require 'vendor/autoload.php';
use Phpml\Dataset\CsvDataset;
$csv = new CsvDataset();
我认为您需要使用 Composer 在项目根目录中安装开发需求
bin/phpunit
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.