addwiki icon indicating copy to clipboard operation
addwiki copied to clipboard

Help installing the library

Open hafizctn opened this issue 4 years ago • 3 comments

Hi everyone, I am a new user and trying to install the library on my hosting. I have followed the guide provided in the readme file. I am getting following error when try to run the project.

Stack trace: #0 {main} thrown in /home/***/public_html/scholars/submit.php on line 6 [21-Nov-2021 09:34:18 UTC] PHP Fatal error: Uncaught Error: Class 'Addwiki\Mediawiki\Api\Client\Action\MediawikiApi' not found in /home/***/public_html/scholars/submit.php:6 Stack trace: #0 {main} thrown in /home/***/public_html/scholars/submit.php on line 6

Following is my php code:


<?php
   // Load all the stuff
require_once($_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php' );

// Create an authenticated API and services
$auth = new \Addwiki\Mediawiki\Api\Client\Auth\UserAndPassword( '***', '***' );
$api = new \Addwiki\Mediawiki\Api\Client\Action\MediawikiApi( 'http://***.com/api.php', $auth );
$services = new \Addwiki\Mediawiki\Api\MediawikiFactory( $api );
// Create a new page
$newContent = new \Addwiki\Mediawiki\DataModel\Content( 'Hello World' );
$title = new \Addwiki\Mediawiki\DataModel\Title( 'Help:Test' );
$identifier = new \Addwiki\Mediawiki\DataModel\PageIdentifier( $title );
$revision = new \Addwiki\Mediawiki\DataModel\Revision( $newContent, $identifier );
$services->newRevisionSaver()->save( $revision );
?>

hafizctn avatar Nov 21 '21 10:11 hafizctn

Hi there!

require_once($_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php' );

This looks a little odd. If you have done a composer install of the code then doing

require_once(__DIR__ . '/vendor/autoload.php' );

in your code should work.

BUt perhaps you are using a different directory layout?

addshore avatar Jan 01 '22 19:01 addshore

I had the same issue. Apparently the examples are outdated since the Class \Addwiki\Mediawiki\Api\Client\Action\MediawikiApi really does not exist in the sources. I was able to fix this by using \Addwiki\Mediawiki\Api\Client\Action\ActionApi instead.

nineff avatar May 24 '22 14:05 nineff

I've had a go at updating some of the docs (see #165). There's more to do for the Action API, and the whole REST API part as well.

samwilson avatar Nov 25 '22 23:11 samwilson