addwiki
addwiki copied to clipboard
Help installing the library
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 );
?>
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?
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.
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.