Codeble-Environment-

LoveGem Framework

Latest Stable Version License PHP Version Build Status Code Style Security

Laravel se better! Privacy-first PHP framework with advanced features.

LoveGem is a modern, privacy-first PHP framework inspired by Laravel. It provides everything you need to build amazing web applications, plus additional features that make it even better than Laravel.

๐Ÿ“š Documentation

๐Ÿ“– Documentation Website


๐Ÿš€ Quick Start

Installation

composer require lovegem/framework

Basic Usage

<?php

declare(strict_types=1);

use LoveGem\Core\Application;
use LoveGem\Container\Container;

// Create application
$app = new Application(__DIR__);

// Register service providers
$app->register(LoveGem\Http\ServiceProvider::class);
$app->register(LoveGem\View\ServiceProvider::class);
$app->register(LoveGem\Database\ServiceProvider::class);

// Use the framework
$app->router->get('/hello', function () {
    return 'Hello from LoveGem!';
});

$app->run();

โœจ Features

Core Framework

HTTP Layer

Database

Authentication

Views

Validation

Session

Cache

Queue

Mail

Events

Logging

Console

Exception Handling


๐Ÿ” Privacy Features (LoveGem Special)

LoveGem puts privacy first with built-in features:

Encryption Service

use LoveGem\Support\Facades\Crypto;

// Encrypt data
$encrypted = Crypto::encrypt('sensitive data');

// Decrypt data
$decrypted = Crypto::decrypt($encrypted);

GDPR Compliance

use LoveGem\Privacy\GDPR;

// Export user data
$userData = GDPR::exportData($user);

// Delete user data
GDPR::deleteData($user);

// Anonymize user data
GDPR::anonymizeData($user);

Data Minimization

use LoveGem\Privacy\DataMinimization;

// Only collect necessary data
DataMinimization::collect($data, [
    'name' => true,      // Required
    'email' => true,     // Required
    'phone' => false,    // Optional - don't collect
    'address' => false,  // Optional - don't collect
]);

๐Ÿš€ Advanced Features (Better than Laravel!)

Task Scheduler

use LoveGem\Scheduler\Schedule;

$schedule = new Schedule();

// Run every 15 minutes
$schedule->call(function () {
    // Cleanup tasks
})->everyFifteenMinutes();

// Run daily at 9 AM
$schedule->command('emails:send')->dailyAt('09:00');

// Run weekly
$schedule->job(new BackupJob)->weekly();

HTTP Client

use LoveGem\Http\Client;

$client = new Client();

// GET request
$response = $client->get('https://api.example.com/users');

// POST with JSON
$response = $client->timeout(10)
    ->withHeaders(['Authorization' => 'Bearer token'])
    ->post('https://api.example.com/users', [
        'name' => 'John',
        'email' => 'john@example.com',
    ]);

// Handle response
if ($response->successful()) {
    $data = $response->json();
}

Rate Limiter

use LoveGem\RateLimiting\RateLimiter;

$rateLimiter = new RateLimiter($cache);

// Limit requests
$rateLimiter->attempt('api', 60, function () {
    return response()->json(['message' => 'Success']);
}, 60); // 60 attempts per minute

Broadcasting (WebSocket)

use LoveGem\Broadcasting\Broadcaster;

$broadcaster = new Broadcaster();

// Define channel
$broadcaster->channel('chat', function ($user) {
    return true;
});

// Broadcast event
$broadcaster->broadcast(['chat'], 'new.message', [
    'user' => $user->name,
    'message' => $message,
]);

File Storage

use LoveGem\Filesystem\Filesystem;

$filesystem = new Filesystem();

// Store file
$filesystem->put('file.txt', 'content', 'local');

// Get file
$content = $filesystem->get('file.txt');

// Delete file
$filesystem->delete('file.txt');

// Check if exists
if ($filesystem->exists('file.txt')) {
    // File exists
}

Notifications

use LoveGem\Notifications\ChannelManager;

$channelManager = new ChannelManager($app);

// Send notification
$notification = new OrderShipped($order);
$channelManager->send($user, $notification);

API Tokens (Sanctum)

use LoveGem\Api\Sanctum;

// Create API token
$token = Sanctum::createApiToken($user, [
    'abilities' => ['posts:read', 'posts:write'],
]);

// Revoke token
Sanctum::revokeApiToken($user, $token);

Health Checks

use LoveGem\Health\HealthChecker;

$health = new HealthChecker();

// Register checks
$health->check('database', function () {
    return $database->ping();
});

$health->check('cache', function () {
    return $cache->ping();
});

// Get report
$report = $health->report();
// ['status' => 'ok', 'checks' => [...]]

Lazy Collections

use LoveGem\Support\LazyCollection\LazyCollection;

// Memory efficient collection
$users = LazyCollection::from($database->cursor());

$users->filter(fn ($user) => $user->active)
    ->map(fn ($user) => $user->name)
    ->each(fn ($name) => echo $name . PHP_EOL);

Fluent Arrays

use LoveGem\Support\Fluent;

$fluent = new Fluent([
    'name' => 'John',
    'email' => 'john@example.com',
]);

echo $fluent->name; // John
echo $fluent->get('email'); // john@example.com

Stringable Objects

use LoveGem\Support\Str;

$string = Str::of('Hello World');

$result = $string->lower()
    ->append('!')
    ->contains('world')
    ->slug();

Webhooks

use LoveGem\Webhooks\WebhookManager;

$webhooks = new WebhookManager();

// Register webhook
$webhooks->register('order.created', 'https://api.example.com/webhook');

// Dispatch webhook
$webhooks->dispatch('order.created', $order);

Profiler (Telescope)

use LoveGem\Profiler\Profiler;

$profiler = Profiler::getInstance();

// Start profiling
$profiler->start('query');

// Execute query
$results = $database->select('SELECT * FROM users');

// Stop profiling
$profiler->stop('query');

// Get report
$report = $profiler->report();

๐ŸŽจ Artisan Commands

# Development
php artisan serve
php artisan tinker

# Database
php artisan migrate
php artisan migrate:rollback
php artisan migrate:refresh
php artisan db:seed

# Generate
php artisan make:model User
php artisan make:controller UserController
php artisan make:migration create_users_table
php artisan make:seeder UserSeeder
php artisan make:test UserTest
php artisan make:policy UserPolicy
php artisan make:middleware AuthMiddleware
php artisan make:command SendEmailsCommand

# Cache
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear

# Security
php artisan key:generate

# Scheduler
php artisan schedule:run
php artisan schedule:list

# Queue
php artisan queue:work
php artisan queue:listen
php artisan queue:failed
php artisan queue:retry

# Health
php artisan health:check
php artisan health:report

๐Ÿ“ Directory Structure

lovegem-framework/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ Console/
โ”‚   โ”‚   โ””โ”€โ”€ Commands/
โ”‚   โ”œโ”€โ”€ Exceptions/
โ”‚   โ”œโ”€โ”€ Http/
โ”‚   โ”‚   โ”œโ”€โ”€ Controllers/
โ”‚   โ”‚   โ”œโ”€โ”€ Middleware/
โ”‚   โ”‚   โ””โ”€โ”€ Requests/
โ”‚   โ”œโ”€โ”€ Models/
โ”‚   โ””โ”€โ”€ Providers/
โ”œโ”€โ”€ bootstrap/
โ”‚   โ””โ”€โ”€ helpers.php
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ app.php
โ”‚   โ”œโ”€โ”€ auth.php
โ”‚   โ”œโ”€โ”€ cache.php
โ”‚   โ”œโ”€โ”€ database.php
โ”‚   โ”œโ”€โ”€ filesystems.php
โ”‚   โ”œโ”€โ”€ logging.php
โ”‚   โ”œโ”€โ”€ mail.php
โ”‚   โ”œโ”€โ”€ queue.php
โ”‚   โ”œโ”€โ”€ services.php
โ”‚   โ””โ”€โ”€ sessions.php
โ”œโ”€โ”€ database/
โ”‚   โ”œโ”€โ”€ factories/
โ”‚   โ”œโ”€โ”€ migrations/
โ”‚   โ””โ”€โ”€ seeders/
โ”œโ”€โ”€ public/
โ”‚   โ””โ”€โ”€ index.php
โ”œโ”€โ”€ resources/
โ”‚   โ”œโ”€โ”€ css/
โ”‚   โ”œโ”€โ”€ js/
โ”‚   โ””โ”€โ”€ views/
โ”œโ”€โ”€ routes/
โ”‚   โ”œโ”€โ”€ api.php
โ”‚   โ”œโ”€โ”€ channels.php
โ”‚   โ”œโ”€โ”€ console.php
โ”‚   โ””โ”€โ”€ web.php
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ Api/
โ”‚   โ”œโ”€โ”€ Auth/
โ”‚   โ”œโ”€โ”€ Broadcasting/
โ”‚   โ”œโ”€โ”€ Cache/
โ”‚   โ”œโ”€โ”€ Config/
โ”‚   โ”œโ”€โ”€ Console/
โ”‚   โ”œโ”€โ”€ Container/
โ”‚   โ”œโ”€โ”€ Core/
โ”‚   โ”œโ”€โ”€ Database/
โ”‚   โ”œโ”€โ”€ Events/
โ”‚   โ”œโ”€โ”€ Exceptions/
โ”‚   โ”œโ”€โ”€ Facades/
โ”‚   โ”œโ”€โ”€ Filesystem/
โ”‚   โ”œโ”€โ”€ Hashing/
โ”‚   โ”œโ”€โ”€ Health/
โ”‚   โ”œโ”€โ”€ Http/
โ”‚   โ”œโ”€โ”€ Logging/
โ”‚   โ”œโ”€โ”€ Mail/
โ”‚   โ”œโ”€โ”€ Notifications/
โ”‚   โ”œโ”€โ”€ Profiler/
โ”‚   โ”œโ”€โ”€ Queue/
โ”‚   โ”œโ”€โ”€ RateLimiting/
โ”‚   โ”œโ”€โ”€ Scheduler/
โ”‚   โ”œโ”€โ”€ Session/
โ”‚   โ”œโ”€โ”€ Support/
โ”‚   โ”œโ”€โ”€ Validation/
โ”‚   โ”œโ”€โ”€ View/
โ”‚   โ””โ”€โ”€ Webhooks/
โ”œโ”€โ”€ storage/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ cache/
โ”‚   โ”œโ”€โ”€ framework/
โ”‚   โ”œโ”€โ”€ logs/
โ”‚   โ””โ”€โ”€ sessions/
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ Feature/
โ”‚   โ””โ”€โ”€ Unit/
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ composer.json
โ”œโ”€โ”€ phpunit.xml.dist
โ”œโ”€โ”€ phpstan.neon
โ”œโ”€โ”€ .php-cs-fixer.dist.php
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ CODE_OF_CONDUCT.md
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ SECURITY.md

๐Ÿ“ฆ Installation

Requirements

Install via Composer

composer create-project lovegem/framework my-app
cd my-app
cp .env.example .env
php artisan key:generate
php artisan serve

Manual Installation

# Clone repository
git clone https://github.com/lovegem-framework/lovegem.git
cd lovegem

# Install dependencies
composer install

# Copy environment file
cp .env.example .env

# Generate application key
php artisan key:generate

# Run migrations
php artisan migrate

# Start development server
php artisan serve

๐Ÿงช Testing

# Run all tests
composer test

# Run unit tests
php vendor/bin/phpunit tests/Unit

# Run feature tests
php vendor/bin/phpunit tests/Feature

# Run with coverage
php vendor/bin/phpunit --coverage-html coverage

# Run static analysis
composer phpstan

# Check code style
composer cs-check

# Fix code style
composer cs-fix

๐Ÿ“š Documentation


๐Ÿค Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

Development Setup

# Clone the repository
git clone https://github.com/lovegem-framework/lovegem.git

# Install dependencies
composer install

# Run tests
composer test

# Check code style
composer cs-check

๐Ÿ› Bug Reports

If you discover a bug, please create an issue on GitHub.


๐Ÿ”’ Security

If you discover a security vulnerability, please see SECURITY.md for details.


๐Ÿ“œ License

LoveGem Framework is open-sourced software licensed under the MIT License.


๐Ÿ™ Credits

LoveGem Framework is inspired by Laravel and built with โค๏ธ by the LoveGem community.

Special Thanks


๐ŸŒŸ Support

If LoveGem Framework helped you, please give us a โญ on GitHub!


๐Ÿ“ง Contact


Made with โค๏ธ by the LoveGem Community