PHP code example of mkamelmasoud / starter-core-kit
1. Go to this page and download the library: Download mkamelmasoud/starter-core-kit 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/ */
mkamelmasoud / starter-core-kit example snippets
use MkamelMasoud\StarterCoreKit\Services\Ai\AiClientService;
// AI Integration - Simple usage
$aiClient = app('ai-client');
$response = $aiClient->ask('Hello, how are you?');
// With system prompt
$aiClient->setPrompt('system', 'You are a helpful assistant');
$response = $aiClient->ask('Write a poem about coding');
// Using specific provider
$aiClient = new AiClientService('openai');
$response = $aiClient->ask('Explain Laravel');
use MkamelMasoud\StarterCoreKit\Core\Repositories\BaseEloquentRepository;
class UserRepository extends BaseEloquentRepository
{
protected function entity(): string
{
return User::class;
}
}
use MkamelMasoud\StarterCoreKit\Core\BaseService;
class UserService extends BaseService
{
protected function getDtoClass(): string
{
return UserDto::class;
}
protected function getRepoClass(): string
{
return UserRepository::class;
}
}
use MkamelMasoud\StarterCoreKit\Traits\Api\ApiResponsesTrait;
class UserController extends Controller
{
use ApiResponsesTrait;
public function index()
{
$users = User::all();
return $this->success('Users retrieved successfully', $users);
}
}
// In your routes/web.php or routes/api.php
Route::middleware(['api', 'starter-core-kit.api-headers'])->group(function () {
// Your API routes
});
Route::middleware(['starter-core-kit.locale'])->group(function () {
// Routes that need locale detection
});