unicodeveloper/laravel-codepen

1.0.1 2015-11-09 03:50 UTC

This package is auto-updated.

Last update: 2024-09-07 17:38:55 UTC


README

Latest Stable Version License Build Status Total Downloads

Laravel 5 的 Codepen 包。非常易于使用。提供 Facades 和依赖注入的使用

安装

需要 PHP 5.5+ 或 HHVM 3.3+,以及 Composer。

首先,通过 Composer 引入该包。

$ composer require unicodeveloper/laravel-codepen

另一种选择是直接将以下行添加到你的 composer.json 文件的 require 块中。

"unicodeveloper/laravel-codepen": "1.0.*"

然后运行 composer installcomposer update 来下载它并更新自动加载器。

将以下内容添加到 config/app.php 中的 providers 数组中

// Laravel 5: config/app.php

'providers' => [
    ...
    Unicodeveloper\Codepen\CodepenServiceProvider::class,
    ...
];

该包还包含一个 Facade

// Laravel 5: config/app.php

'aliases' => [
    ...
    'Codepen' => Unicodeveloper\Codepen\Facades\Codepen::class,
    ...
]

使用方法

CodepenManager

这是最感兴趣的类。它绑定到 ioc 容器上的 'laravel-codepen',可以使用 Facades\Codepen Facade 访问。

Facades\Codepen

此 Facade 将将静态方法调用动态传递到 ioc 容器中的 'laravel-codepen' 对象上,默认情况下是 CodepenManager 类。

示例

这里可以看到这个包有多么简单易用。

use Unicodeveloper\Codepen\Facades\Codepen;
// or you can alias this in config/app.php like I mentioned initially above

Codepen::getMostPopularPens();
// returns an array containing 12 results of the most popular codepens

Codepen::getLatestPickedPens();
// returns an array containing 12 results of the latest picked codepens

Codepen::getRecentlyCreatedPens();
// returns an array containing 12 results of the most recently created codepens

Codepen::getProfile($username);
// returns an object containing the profile of a user . e.g $username is chriscoyier
{#169 ▼
  +"nicename": "Chris Coyier"
  +"username": "chriscoyier"
  +"avatar": "//s3-us-west-2.amazonaws.com/s.cdpn.io/3/profile/profile-512_22.jpg"
  +"location": "Milwaukee, WI"
  +"bio": "I'm kinda into this whole CodePen thing."
  +"pro": true
  +"followers": "6399"
  +"following": "1165"
  +"links": array:3 [▶]
}

Codepen::user('chriscoyier')->location;
// returns Milwaukee, WI

Codepen::user('chriscoyier')->nicename;
// returns Chris Coyier

Codepen::user('chriscoyier')->username;
// returns chriscoyier

Codepen::user('chriscoyier')->avatar;
// returns //s3-us-west-2.amazonaws.com/s.cdpn.io/3/profile/profile-512_22.jpg

Codepen::user('chriscoyier')->bio;
// returns I'm kinda into this whole CodePen thing.

Codepen::user('chriscoyier')->followers;
// returns 6399

Codepen::user('chriscoyier')->following;
// returns 1165

Codepen::getLovedPosts($username);
//  e.g sample $username is chriscoyier, returns an array of his most loved posts

Codepen::getPopularPosts($username);
// e.g sample $username is chriscoyier, returns an array of his most popular posts

Codepen::getPublishedPosts($username);
// e.g sample $username is chriscoyier, returns an array of his most published posts

Codepen::getLovedPens($username);
// e.g sample $username is chriscoyier, returns an array of his most loved pens

Codepen::getPopularPens($username);
// e.g sample $username is chriscoyier, returns an array of his most popular pens

Codepen::getPublicPens($username);
// e.g sample $username is chriscoyier, returns an array of his public pens

Codepen::getForkedPens($username);
// e.g sample $username is chriscoyier, returns an array of his most forked pens

变更日志

有关最近更改的更多信息,请参阅CHANGELOG

测试

您可以使用以下命令运行测试

vendor/bin/phpunit run

或者,您可以像这样运行测试

composer test

贡献

有关详细信息,请参阅CONTRIBUTING

致谢

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅许可证文件

安全

如果您发现任何与安全相关的问题,请通过电子邮件 prosperotemuyiwa@gmail.com 联系,而不是使用问题跟踪器。