PHP code example of sharpapi / laravel-skills-database-api

1. Go to this page and download the library: Download sharpapi/laravel-skills-database-api 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/ */

    

sharpapi / laravel-skills-database-api example snippets




namespace App\Http\Controllers;

use GuzzleHttp\Exception\GuzzleException;
use SharpAPI\SkillsDatabaseApi\SkillsDatabaseApiService;

class SkillsController extends Controller
{
    protected SkillsDatabaseApiService $skillsService;

    public function __construct(SkillsDatabaseApiService $skillsService)
    {
        $this->skillsService = $skillsService;
    }

    /**
     * @throws GuzzleException
     */
    public function searchSkills(string $query)
    {
        $results = $this->skillsService->searchSkills($query);
        
        return response()->json($results);
    }

    /**
     * @throws GuzzleException
     */
    public function getSkillDetails(string $skillId)
    {
        $skill = $this->skillsService->getSkillById($skillId);
        
        return response()->json($skill);
    }
}

use GuzzleHttp\Exception\ClientException;

try {
    $skills = $this->skillsService->searchSkills('programming');
} catch (ClientException $e) {
    echo $e->getMessage();
}
bash
php artisan vendor:publish --tag=sharpapi-skills-database-api
bash
SHARP_API_KEY=your_api_key_here
SHARP_API_BASE_URL=https://sharpapi.com/api/v1