PHP code example of pacific-softwares / projectscore
1. Go to this page and download the library: Download pacific-softwares/projectscore 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/ */
pacific-softwares / projectscore example snippets
use ProjectsCore\Facades\ProjectsCore;
// Get the API base URL
$baseUrl = ProjectsCore::getBaseUrl();
// Check if API is configured
if (ProjectsCore::isConfigured()) {
// API is available
}
// Build a full URL from a path
$url = ProjectsCore::url('users/123');
// Make GET request
$response = ProjectsCore::get('users', ['page' => 1]);
$users = $response->json();
// Make POST request
$response = ProjectsCore::post('users', [
'name' => 'John Doe',
'email' => '[email protected]'
]);
$user = $response->json();
// Make PUT request
$response = ProjectsCore::put('users/123', [
'name' => 'Jane Doe'
]);
// Make PATCH request
$response = ProjectsCore::patch('users/123', [
'email' => '[email protected]'
]);
// Make DELETE request
$response = ProjectsCore::delete('users/123');
use ProjectsCore\Services\ApiService;
$apiService = app('projectscore.api');
$baseUrl = $apiService->getBaseUrl();
// Make requests
$response = $apiService->get('users');
$data = $response->json();
$response = ProjectsCore::get('users');
// Check if request was successful
if ($response->successful()) {
$data = $response->json();
}
// Get status code
$statusCode = $response->status();
// Get response body as array
$data = $response->json();
// Get response body as string
$body = $response->body();
// Check for errors
if ($response->failed()) {
// Handle error
}