Composer AutoLoading

Hello,
I would like to use this library: https://github.com/wamania/php-stemmer

I have downloaded the repository, changed the composer.json as following (I need it on a very old PHP environment):

{
	"name": "wamania/php-stemmer[1.3]",
	"description": "Native PHP Stemmer",
	"keywords": ["stemmer", "porter", "php"],
	"license": "MIT",
	"authors": [
		{
			"name": "Wamania",
			"homepage": "http://wamania.com"
		}
	],
	"require": {
		"php": ">=5.0",
		"voku/portable-utf8": "^5.4"
	},
	"require-dev":{
		"phpunit/phpunit": "^5.0"
	},
	"autoload": {
		"psr-4": {
			"Wamania\\Snowball\\": "src/"
		}
	},
	"autoload-dev": {
		"psr-4": {
			"Wamania\\Snowball\\Tests\\": "test/"
		}
	}
}

And then used successfully “composer install” and “composer dump-autoload”. Now, if I create a file tester.php like this:

<?php

require __DIR__ . '/vendor/autoload.php';

use Wamania\Snowball\French;

$stemmer = new French();
$stem = $stemmer->stem('anticonstitutionnellement');

It just says PHP Fatal error: Uncaught Error: Class ‘Wamania\Snowball\French’ not found in /home/me/php-stemmer-master/test.php:7

What am I missing? Thank you

Are you sure you want the “test” directory? That would be for the unit tests, now class definitions.

That’s not how composer works; the composer.json that comes with the package you wish to use should not be edited. You create a composer.json for your own program and populate that with the packages you require. If you’re working with PHP 5.0, composer won’t even run - its minimum version is 5.3.

Sponsor our Newsletter | Privacy Policy | Terms of Service