laravel-wikipedia
, (*1)
Laravel Package to work with Wikipedia. Very easy to use. Offers the use of Facades and Dependency Injection, (*2)
Installation
PHP 5.5+ or HHVM 3.3+, and Composer are required., (*3)
First, pull in the package through Composer., (*4)
``` bash
$ composer require unicodeveloper/laravel-wikipedia, (*5)
Another alternative is to simply add the following line to the require block of your `composer.json` file.
"unicodeveloper/laravel-wikipedia": "1.0.*", (*6)
Then run `composer install` or `composer update` to download it and have the autoloader updated.
And then include these service providers within `config/app.php`
```php
'providers' => [
...
Unicodeveloper\Larapedia\WikiRandServiceProvider::class,
...
];
This package also comes with a Facade, (*7)
'aliases' => [
...
'WikiRand' => Unicodeveloper\Larapedia\WikiRandFacade::class,
...
]
Run the following command, it creates a config/wikirand.php in your laravel app. You can modify the configuration, (*8)
php artisan vendor:publish
Usage
Use it like so:, (*9)
For those that love Facades immensely, I have provided the cake for you :smile: like so:, (*10)
``` php, (*11)
{{ WikiRand::getFirstSentence() }} // returns 5321 Jagras è un asteroide della fascia principale., (*12)
{{ WikiRand::getApiLanguage() }} // returns it, (*13)
{{ WikiRand::getId() }} // returns 812464, (*14)
{{ WikiRand::getTitle() }} // returns 5321 Jagras, (*15)
{{ WikiRand::getLink() }} // returns http://it.wikipedia.org/wiki/5321_Jagras, (*16)
{{ WikiRand::getNChar(25) }} // 5321 Jagras è un asteroide..., (*17)
{{ WikiRand::getCategoriesRelated() }}
// returns
array(3) {
[0]=> string(42) "Asteroidi della fascia principale centrale"
[1]=> string(31) "Corpi celesti scoperti nel 1985"
[2]=> string(16) "Stub - asteroidi"
}, (*18)
{{ WikiRand::getOtherLangLinks() }}
// returns
array(10)
{ [0]=> array(3)
{ ["lang"]=> string(2) "en"
["url"]=> string(40) "http://en.wikipedia.org/wiki/5321_Jagras"
[""]=> string(11) "5321 Jagras" }
[1]=> array(3) {
["lang"]=> string(2) "eo"
["url"]=> string(41) "http://eo.wikipedia.org/wiki/5321_Jagraso"
[""]=> string(12) "5321 Jagraso" }
[2]=> array(3) {
["lang"]=> string(2) "fa"
["url"]=> string(84) "http://fa.wikipedia.org/wiki/%D8%B3%DB%8C%D8%A7%D8%B1%DA%A9_%DB%B5%DB%B3%DB%B2%DB%B1" [""]=> string(19) "سیا" }
[3]=> array(3) {
["lang"]=> string(2) "hu"
["url"]=> string(40) "http://hu.wikipedia.org/wiki/5321_Jagras"
[""]=> string(11) "5321 Jagras" }
[4]=> array(3) {
["lang"]=> string(2) "hy"
["url"]=> string(72) "http://hy.wikipedia.org/wiki/(5321)%D5%8B%D5%A1%D5%A3%D6%80%D5%A1%D5%BD"
[""]=> string(19) "(5321) Ջագրաս" }
[5]=> array(3) {
["lang"]=> string(2) "la"
["url"]=> string(40) "http://la.wikipedia.org/wiki/5321_Jagras"
[""]=> string(11) "5321 Jagras" }
[6]=> array(3) {
["lang"]=> string(2) "oc"
["url"]=> string(40) "http://oc.wikipedia.org/wiki/5321_Jagras"
[""]=> string(11) "5321 Jagras" }
[7]=> array(3) {
["lang"]=> string(2) "pl"
["url"]=> string(42) "http://pl.wikipedia.org/wiki/(5321)_Jagras"
[""]=> string(13) "(5321) Jagras" }
[8]=> array(3) {
["lang"]=> string(2) "pt"
["url"]=> string(40) "http://pt.wikipedia.org/wiki/5321_Jagras"
["*"]=> string(11) "5321 Jagras" }
[9]=> array(3) {
["lang"]=> string(2) "uk"
["url"]=> string(64) "http://uk.wikipedia.org/wiki/5321%D0%AF%D2%91%D1%80%D0%B0%D1%81"
["*"]=> string(15) "5321 Яґрас"
}
}, (*19)
{{ WikiRand::getPlainTextArticle() }}
// returns
5321 Jagras è un asteroide della fascia principale. Scoperto nel 1985, presenta un'orbita caratterizzata da un semiasse maggiore pari a 2,5810209 UA e da un'eccentricità di 0,2213576, inclinata di 13,58746° rispetto all'eclittica. Collegamenti esterni (EN) Jagras - Dati riportati nel database dell'IAU Minor Planet Center (EN) Jagras - Dati riportati nel Jet Propulsion Laboratory - Small-Body Database, (*20)
{{ WikiRand::getArticleImages() }}
// returns
array(2) {
[0]=> string(63) "http://upload.wikimedia.org/wikipedia/commons/8/83/Celestia.png"
[1]=> string(76) "http://upload.wikimedia.org/wikipedia/commons/9/9a/Galileo_Gaspra_Mosaic.jpg"
}, (*21)
## Change log
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Testing
You can run the tests with:
```bash
vendor/bin/phpunit run
Alternatively, you can run the tests like so:, (*22)
composer test
Inspiration
Contributing
Please see CONTRIBUTING for details., (*23)
How can I thank you?
Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!, (*24)
Don't forget to follow me on twitter!, (*25)
Thanks!
Prosper Otemuyiwa., (*26)
License
The MIT License (MIT). Please see License File for more information., (*27)
Security
If you discover any security related issues, please email prosperotemuyiwa@gmail.com instead of using the issue tracker., (*28)