Composer and SemanticMediaWiki

Machine Learning Artificial Intelligence Natural Language Processing Semantic Web Ontology Technology Digital Transformation Web Technology User Interface Reasoning Technology Knowledge Information Processing Chatbot and Q&A Technology PHP and Web Development Search Technology DataBase Technology Algorithm Workflow & Services Navigation of this blog 

Composer and SemanticMediaWiki

Composer will be an application-level package management system that provides a standard format for managing software and necessary library dependencies for the PHP programming language.

It runs on the command line and installs the libraries and other software on which the application depends. It can also install PHP applications available in the main “Packagist” repository, which contains available packages, and provides the ability to specify autoloading information for libraries to facilitate the use of third-party code.

It is also an important part of the functionality of well-known open source PHP projects, including Laravel.

First, let’s talk about the installation of the Composer, which can be found on the official Composer page

Select Download and the following page will appear.

Now copy the following code from the above page and execute it in the terminal respectively.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Composer successfully installed… is displayed at the end, the download is complete.

(In the case of macs, move the composer.phar file to the global directory to run composer. (If /usr/local/bin directory does not exist, create it. sudo mkdir -p /usr/local/bin”)

sudo mv composer.phar /usr/local/bin/composer

If the installation and pass-through are complete, type “composer -V” in the terminal to see the version.

To use Composer, you must create a composer.json file.
The composer.json file will be a file that describes the library information you want to install in the project, and should be created for each project.

For example, when you create a project as follows

mkdir composer_project
cd composer_project

Create a composer.json file like the following and place it under the above directory.

//composer_project/composer.json

{
    "require": {
        "monolog/monolog": "1.0.*"
    }
}

After “require”, specify the library to be installed by its package name:version number. In addition, the following installation will place the libraries in the directory with their dependencies taken into account.

composer install

Next, we describe the Semantic MediaWiki, which is described in detail in “Semantic Media Wiki“. In this article, we describe how to set them up.

First, to generate a local composer.phar in the MediaWiki directory (in the htdocs folder in the MAMP folder if you have followed the instructions in this blog), do the following

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Confirm that composer.phar has been generated in the folder.

Next, change the file name of the “composer.local.json-sample” file in the mw folder to “composer.local.json”.

Next, execute the following PHP commands in the directory containing the mw folder.

COMPOSER=composer.local.json php composer.phar require --no-update mediawiki/semantic-media-wiki

In addition, execute the following commands

composer update --no-dev

Next, open the “LocalSettings.php” file in the mw folder and add the following code

## SEmantic MediaWikiwfLoadExtension( 'SemanticMediaWiki' ); enableSemantics( 'example.org' );

Finally, run the following setup and update commands

php maintenance/update.php

コメント

タイトルとURLをコピーしました