PHPackages                             turahe/core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. turahe/core

ActiveLibrary[Framework](/categories/framework)

turahe/core
===========

A comprehensive Laravel package providing core functionality for modern web applications, including image processing, OAuth integration, taxonomy management, organization handling, and utility helpers.

v1.4.1(8mo ago)01583MITPHPPHP ^8.4

Since Dec 19Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/turahe/core)[ Packagist](https://packagist.org/packages/turahe/core)[ RSS](/packages/turahe-core/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (13)Versions (12)Used By (3)

Turahe Core
===========

[](#turahe-core)

[![CI](https://github.com/turahe/core/actions/workflows/ci.yml/badge.svg)](https://github.com/turahe/core/actions/workflows/ci.yml)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/bfb98d885e37493cddcc01059ebf02a8872de9da37c12691b8bb6d13fcdca735/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342532422d626c75652e737667)](https://php.net)[![Laravel Version](https://camo.githubusercontent.com/2c3c8e91a3f0bca708c77b11d1eeaab0292356b823054f95866653594ff8a1d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322532422d7265642e737667)](https://laravel.com)[![Packagist](https://camo.githubusercontent.com/acd676633b63d3b53fa3bcc3f0cfffd5a8d586f78462b20412b7289b0381824d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5061636b61676973742d747572616865253246636f72652d626c75652e737667)](https://packagist.org/packages/turahe/core)[![Packagist Downloads](https://camo.githubusercontent.com/a734da6826e9cab22a3d2ecf497bad6bc404381a314510db6b48bcfe99ded45d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f776e6c6f6164732d302d626c75652e737667)](https://packagist.org/packages/turahe/core)

A comprehensive Laravel package providing core functionality for modern web applications including image processing, OAuth integration, taxonomy management, organization handling, and utility helpers.

🚀 Features
----------

[](#-features)

### 📸 Image Processing

[](#-image-processing)

- **ImgProxy Integration**: Secure image URL signing and processing
- **Image Optimization**: Automatic resizing, cropping, and format conversion
- **Preset Support**: Predefined image processing configurations
- **Signature Verification**: Secure image URL validation

### 🔐 OAuth Integration

[](#-oauth-integration)

- **Google OAuth**: Complete Google API integration with Calendar, Gmail, and Drive
- **Microsoft Graph**: Full Microsoft Graph API support for Office 365 services
- **Token Management**: Automatic token refresh and storage
- **Resource Owners**: Custom resource owner implementations

### 🏷️ Taxonomy &amp; Tagging

[](#️-taxonomy--tagging)

- **Hierarchical Taxonomies**: Nested set implementation for complex categorization
- **Flexible Tagging**: Polymorphic tagging system for any model
- **Slug Generation**: Automatic slug creation with Spatie Laravel Sluggable
- **Sortable Content**: Drag-and-drop ordering with Spatie Eloquent Sortable

### 🏢 Organization Management

[](#-organization-management)

- **Multi-tenant Support**: Organization-based data isolation
- **Role-based Access**: Member, Admin, and Owner roles
- **Hierarchical Structure**: Nested organization trees
- **User Associations**: Flexible user-organization relationships

### 📧 Email Services

[](#-email-services)

- **Gmail Integration**: Full Gmail API support with message handling
- **Microsoft Graph Email**: Outlook/Exchange email integration
- **Attachment Processing**: Automatic email attachment handling
- **Message Composition**: Rich email composition features

### 🛠️ Utility Helpers

[](#️-utility-helpers)

- **Currency Formatting**: `format_currency()` for consistent money display
- **Name Aliases**: `name_alias()` for user-friendly name display
- **Text Cleaning**: `clean()` for sanitized text output
- **Acronym Generation**: `acronym()` for abbreviation creation
- **Image URLs**: `imgProxy()` and `imgProxyPreset()` for secure image URLs
- **Percentage Calculations**: `calculate_percentage()` for mathematical operations
- **Phone Parsing**: `parse_phone()` for international phone number handling

📦 Installation
--------------

[](#-installation)

### Requirements

[](#requirements)

- PHP 8.4 or higher
- Laravel 12
- SQLite (for testing)
- Redis (optional, for production caching)

### Via Composer

[](#via-composer)

```
composer require turahe/core
```

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --provider="Turahe\Core\CoreServiceProvider"
```

### Run Migrations

[](#run-migrations)

```
php artisan migrate
```

📚 Documentation
---------------

[](#-documentation)

For comprehensive documentation, guides, and technical details, visit the [docs/](docs/) directory:

- **[📖 Documentation Index](docs/README.md)** - Complete documentation overview
- **[🧪 Testing Guide](docs/TESTING_SUMMARY.md)** - Testing setup and guidelines
- **[🔧 Scripts &amp; Tools](scripts/)** - Utility scripts and automation

⚙️ Configuration
----------------

[](#️-configuration)

### Environment Variables

[](#environment-variables)

```
# Database Configuration
DB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite

# Cache Configuration (Array driver for testing, Redis for production)
CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_CONNECTION=sync

# Redis Configuration (Optional, for production)
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

# Core Package Configuration
CORE_TABLE_USE_TIMESTAMPS=false
USERSTAMPS_USERS_TABLE_COLUMN_TYPE=ulid
APP_KEY=your-app-key

# Table Names (Customizable)
CORE_TABLE_SETTINGS=settings
CORE_TABLE_ORGANIZATIONS=organizations
CORE_TABLE_MODEL_HAS_ORGANIZATION=model_has_organization
CORE_TABLE_TAXONOMIES=taxonomies
CORE_TABLE_MODEL_HAS_TAXONOMIES=model_has_taxonomies
CORE_TABLE_TAGS=tags
CORE_TABLE_TAGGABLES=taggables
CORE_TABLE_OAUTH_ACCOUNTS=oauth_accounts

# Cache Configuration
CORE_CACHE_ENABLED=true
CORE_CACHE_SETTINGS_TTL=3600
```

### Google OAuth Setup

[](#google-oauth-setup)

```
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=your-redirect-uri
```

### Microsoft Graph Setup

[](#microsoft-graph-setup)

```
MSGRAPH_CLIENT_ID=your-ms-client-id
MSGRAPH_CLIENT_SECRET=your-ms-client-secret
MSGRAPH_REDIRECT_URI=your-redirect-uri
```

### ImgProxy Configuration

[](#imgproxy-configuration)

```
IMGPROXY_URL=your-imgproxy-url
IMGPROXY_KEY=your-imgproxy-key
IMGPROXY_SALT=your-imgproxy-salt
```

🔧 Usage
-------

[](#-usage)

### Service Providers

[](#service-providers)

The package automatically registers the `CoreServiceProvider`. You can also manually register it in `config/app.php`:

```
'providers' => [
    // ...
    Turahe\Core\CoreServiceProvider::class,
],
```

### Facades

[](#facades)

The package provides convenient facades for Google and Microsoft services:

```
use Turahe\Core\Facades\Google;
use Turahe\Core\Facades\MsGraph;

// Google Services
Google::calendar()->listEvents();
Google::gmail()->sendMessage($message);

// Microsoft Graph Services
MsGraph::calendar()->getEvents();
MsGraph::mail()->sendMessage($message);
```

### Helper Functions

[](#helper-functions)

```
// Currency formatting
echo format_currency(1234.56, 'USD'); // $1,234.56

// Name aliases
echo name_alias('John Doe'); // J. Doe

// Text cleaning
echo clean('alert("xss")'); // alert("xss")

// Acronyms
echo acronym('World Health Organization'); // WHO

// Image URLs
echo imgProxy('https://example.com/image.jpg', 800, 600);
echo imgProxyPreset('https://example.com/image.jpg', 'thumbnail');

// Percentage calculations
echo calculate_percentage(25, 100); // 25.0

// Phone parsing
echo parse_phone('+1-555-123-4567'); // +15551234567
```

### Models and Traits

[](#models-and-traits)

#### HasOrganization Trait

[](#hasorganization-trait)

```
use Turahe\Core\Concerns\HasOrganization;

class User extends Authenticatable
{
    use HasOrganization;

    // Your model implementation
}

// Usage
$user = User::find(1);
$user->organizations()->attach($organizationId, ['role' => 'MEMBER']);
$user->managedOrganizations; // Organizations where user is admin/owner
```

#### HasSettings Trait

[](#hassettings-trait)

```
use Turahe\Core\Concerns\HasSettings;

class User extends Authenticatable
{
    use HasSettings;

    // Your model implementation
}

// Usage
$user = User::find(1);
$user->updateSetting('theme', 'dark');
$user->getSetting('theme', 'light'); // Returns 'dark' or default 'light'
$user->allSettings(); // Get all settings
```

#### HasTaxonomies Trait

[](#hastaxonomies-trait)

```
use Turahe\Core\Concerns\HasTaxonomies;

class Post extends Model
{
    use HasTaxonomies;

    // Your model implementation
}

// Usage
$post = Post::find(1);
$post->taxonomies()->attach($categoryId);
$post->taxonomies; // Get all taxonomies
```

#### HasTags Trait

[](#hastags-trait)

```
use Turahe\Core\Concerns\HasTags;

class Post extends Model
{
    use HasTags;

    // Your model implementation
}

// Usage
$post = Post::find(1);
$post->tags()->attach($tagId);
$post->tags; // Get all tags
```

### Repositories

[](#repositories)

```
use Turahe\Core\Repositories\OrganizationRepository;

$repository = app(OrganizationRepository::class);

// Get all organizations
$organizations = $repository->getOrganizations();

// Get organization by ID
$organization = $repository->getOrganization(1);

// Get organization by name
$organization = $repository->getOrganizationByName('Acme Corp');

// Create organization
$organization = $repository->createOrganization([
    'name' => 'New Organization',
    'slug' => 'new-organization',
    'type' => 'company'
]);
```

🧪 Testing
---------

[](#-testing)

### Running Tests

[](#running-tests)

```
# Run all tests
vendor/bin/phpunit

# Run specific test suite
vendor/bin/phpunit --testsuite=Unit
vendor/bin/phpunit --testsuite=Feature

# Run with coverage
vendor/bin/phpunit --coverage-html coverage-report
```

### Local Testing

[](#local-testing)

```
# Run tests locally
vendor/bin/phpunit

# Run with coverage
vendor/bin/phpunit --coverage-html coverage-report
```

### Test Coverage

[](#test-coverage)

- **Unit Tests**: 196 tests with 418 assertions
- **Feature Tests**: 250 tests with 799 assertions
- **Total Tests**: 446 tests with 1,217 assertions
- **Coverage**: Comprehensive coverage of all package features
- **Database**: SQLite in-memory for fast, isolated testing

🧪 Testing &amp; Quality
-----------------------

[](#-testing--quality)

### Current Status ✅

[](#current-status-)

- **All 446 tests passing** with comprehensive coverage
- **SQLite in-memory database** for fast, isolated testing
- **No environment variables needed** - all configuration is hardcoded
- **Xdebug coverage** working correctly
- **GitHub Actions CI** fully functional with SQLite-only setup
- **UserStamps integration** working with ULID primary keys
- **Eloquent relationships** properly tested and validated
- **Code formatting** follows Laravel Pint standards

### Test Suites

[](#test-suites)

- **Unit Tests**: Core functionality, models, repositories, services
- **Feature Tests**: Database integration, traits, migrations
- **Migration Tests**: All database schema variations (ULID, UUID, BigIncrements)
- **Repository Tests**: CRUD operations and custom methods
- **Trait Tests**: HasOrganization, HasSettings, HasTags, HasTaxonomies

### Code Quality

[](#code-quality)

- **Laravel Pint**: Automatic code formatting with Laravel preset
- **Consistent Style**: All code follows Laravel coding standards
- **PHPDoc**: Comprehensive documentation with proper formatting
- **Clean Code**: Proper spacing, line endings, and structure

🧪 Local Development
-------------------

[](#-local-development)

### Quick Start

[](#quick-start)

```
# Install dependencies
composer install

# Run tests
vendor/bin/phpunit

# Generate coverage report
vendor/bin/phpunit --coverage-html coverage-report
```

### Testing Environment

[](#testing-environment)

- **PHP 8.4+**: Required for development
- **SQLite**: In-memory database for testing (no file setup needed)
- **Array Cache**: In-memory cache driver for testing
- **Xdebug**: Required for coverage reports
- **Composer**: Dependency management
- **No .env file needed**: All configuration is hardcoded in TestCase.php

### Development Tools

[](#development-tools)

- **Laravel Pint**: Code formatting and style enforcement
- **Coverage Scripts**: Automated test coverage generation
- **Git Hooks**: Pre-commit formatting checks (optional)
- **IDE Support**: Full IDE integration with proper formatting

📊 CI/CD
-------

[](#-cicd)

The package includes streamlined GitHub Actions workflows focused on testing:

- **CI Tests**: PHP 8.4 + Laravel 12 testing with SQLite in-memory
- **Coverage**: Xdebug coverage reports uploaded to Codecov
- **Dependabot**: Automated dependency updates with testing
- **Releases**: Test validation before release

🤝 Contributing
--------------

[](#-contributing)

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

### Development Setup

[](#development-setup)

```
# Clone repository
git clone https://github.com/turahe/core.git
cd core

# Install dependencies
composer install

# Run tests (no .env file needed - uses SQLite in-memory)
vendor/bin/phpunit

# Run tests with coverage
scripts/coverage.bat  # Windows
scripts/coverage.sh   # Linux/macOS
```

📝 License
---------

[](#-license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

👨‍💻 Author
----------

[](#‍-author)

**Nur Wachid** -

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- [Laravel](https://laravel.com) - The web framework
- [Spatie](https://spatie.be) - Laravel packages
- [Google APIs](https://developers.google.com) - Google services
- [Microsoft Graph](https://docs.microsoft.com/graph) - Microsoft services
- [ImgProxy](https://imgproxy.net) - Image processing
- [Orchestra Testbench](https://github.com/orchestral/testbench) - Package testing

---

**Made with ❤️ for the Laravel community**

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance58

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~27 days

Recently: every ~15 days

Total

10

Last Release

268d ago

PHP version history (2 changes)v1.0PHP ^8.2

v1.3.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/f3513bd6100438bcb8c6b1a7e241a66e1ddaf1c11ee33883e06ef4a2784120db?d=identicon)[turahe](/maintainers/turahe)

---

Top Contributors

[![turahe](https://avatars.githubusercontent.com/u/6832622?v=4)](https://github.com/turahe "turahe (54 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/turahe-core/health.svg)

```
[![Health](https://phpackages.com/badges/turahe-core/health.svg)](https://phpackages.com/packages/turahe-core)
```

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[krayin/laravel-crm

Krayin CRM

22.0k32.8k1](/packages/krayin-laravel-crm)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1225.0k10](/packages/fleetbase-core-api)[chameleon-system/chameleon-base

The Chameleon System core.

1026.5k3](/packages/chameleon-system-chameleon-base)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
