PHP code example of unicodeveloper / laravel-codepen

1. Go to this page and download the library: Download unicodeveloper/laravel-codepen library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

unicodeveloper / laravel-codepen example snippets


// Laravel 5: config/app.php

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

// Laravel 5: config/app.php

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

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