PHPackages                             rupeshstha/core-foundation - 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. [API Development](/categories/api)
4. /
5. rupeshstha/core-foundation

ActiveLibrary[API Development](/categories/api)

rupeshstha/core-foundation
==========================

A foundational package for streamlined development, offering essential core functionality and components to accelerate project creation and enhance scalability.

0.0.3(1mo ago)147MITPHPPHP ^8.3|^8.4CI passing

Since Jul 30Pushed 4w agoCompare

[ Source](https://github.com/rupeshstha/core-foundation)[ Packagist](https://packagist.org/packages/rupeshstha/core-foundation)[ Docs](https://github.com/rupeshstha/core-foundation)[ GitHub Sponsors](https://github.com/rupeshstha)[ RSS](/packages/rupeshstha-core-foundation/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (3)Dependencies (24)Versions (5)Used By (0)

Streamlined Foundations for Robust Development
==============================================

[](#streamlined-foundations-for-robust-development)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dca3f4455b85e1b48efca0dc0e186036ca65c5ed0aa2dbbc8362938975739ddd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f727570657368737468612f636f72652d666f756e646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rupeshstha/core-foundation)[![Total Downloads](https://camo.githubusercontent.com/19b2b7985f29215ba61299aa260acf4fe411bb7f327ed5741300b43dc31c9d15/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f727570657368737468612f636f72652d666f756e646174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rupeshstha/core-foundation)

[![https://core-foundation-doc.rupeshstha.com.np/?ref=github](https://camo.githubusercontent.com/80976f64fc2222a3b4d52c45e631a83a2a91583a0b0ac918e5a139579ba830bc/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f72757065736873746861253246636f72652d666f756e646174696f6e2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d72757065736873746861253246636f72652d666f756e646174696f6e267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d412b666f756e646174696f6e616c2b7061636b6167652b666f722b73747265616d6c696e65642b646576656c6f706d656e742532432b6f66666572696e672b657373656e7469616c2b636f72652b66756e6374696f6e616c6974792b616e642b636f6d706f6e656e74732b746f2b616363656c65726174652b70726f6a6563742b6372656174696f6e2b616e642b656e68616e63652b7363616c6162696c6974792e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d686f6d65267769647468733d323030)](https://camo.githubusercontent.com/80976f64fc2222a3b4d52c45e631a83a2a91583a0b0ac918e5a139579ba830bc/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f72757065736873746861253246636f72652d666f756e646174696f6e2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d72757065736873746861253246636f72652d666f756e646174696f6e267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d412b666f756e646174696f6e616c2b7061636b6167652b666f722b73747265616d6c696e65642b646576656c6f706d656e742532432b6f66666572696e672b657373656e7469616c2b636f72652b66756e6374696f6e616c6974792b616e642b636f6d706f6e656e74732b746f2b616363656c65726174652b70726f6a6563742b6372656174696f6e2b616e642b656e68616e63652b7363616c6162696c6974792e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d686f6d65267769647468733d323030)

`core-foundation` is a foundational package for streamlined development, offering essential core functionality and components to accelerate project creation and enhance scalability. It replaces hand-rolled base classes with highly opinionated, extensible, and Octane-safe abstractions.

This foundation is built for developers creating modular monoliths who require strong conventions, structured extensibility, and built-in observability out of the box.

Key Features
------------

[](#key-features)

- **Modular Extensibility:** Extend `BaseModel`, `BaseResource`, `BaseService`, and Repositories across module boundaries without modifying the source module. Uses structured Service Provider hooks (`extendModels`, `extendResources`, etc.).
- **Application Context:** Collision-safe, domain-scoped state management using `ApplicationContext`, optimized for long-running processes.
- **Consistent Response Envelopes:** Enforces a uniform application response shape (`message`, `payload`, `meta`, `errors`, `exception_id`) across all successful and failed endpoints using `BaseController`.
- **Three-Layer Exception Handling:** Features a predictable error system with an `ExceptionRenderer` (handles framework exceptions), `BaseApiException` (domain exceptions), and `handleException()` (fatal controller safety net with UUIDs).
- **Built-in Server-Timing Profiling:** Gain real-time performance insights directly in browser DevTools. Auto-measure pipelines, cache hit/miss rates, and query times via `ServerTimingMiddleware`.
- **Octane Safety:** Ensures complete safety in long-running processes (Laravel Octane). Contexts are scoped and reset per request automatically.
- **Race Condition Handling:** Native support for Pessimistic Locking (`lockForUpdate`, `sharedLock`) and Atomic Updates (Compare-and-Swap) via `updateAtomic` in repositories to prevent lost updates in high-concurrency scenarios.
- **Repository Pattern &amp; Caching:** Advanced `BaseRepository` with `FilterApplicator` and `SortApplicator`. Built-in tag-based read-through caching that automatically invalidates upon create, update, and delete actions. Supports proactive **Parallel Cache Warming** via background jobs.
- **Security &amp; Authentication:** Secure **httpOnly Cookie-based Authentication** out of the box via `AuthenticateWithCookie` and `SetAuthCookie` middleware. Auth guard is config-driven — works with Sanctum, Passport, JWT, or any custom guard without modifying the package.
- **WebSocket &amp; Real-time Foundation:** Structured base for broadcasting events (`BaseBroadcastEvent`, `TenantBroadcastEvent`) with built-in tenant isolation and a secure **Cookie-aware Authorization Controller**.
- **DTOs and Pipelines:** Standardized `BaseDataObject` (DTOs) and `HasPipeline` / `HasEvent` traits to enforce clean data transitions and logic decoupling.
- **Built-in AI Assistant Context (Agentic Skills):** This package ships with expert-level `.md` rule files and guidelines (located in `resources/boost/skills/core-foundation-best-practices`). When used with an AI coding assistant, it instantly provides the AI with the exact architecture rules, patterns, and conventions of CoreFoundation, ensuring your AI writes compliant code from day one.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require rupeshstha/core-foundation
```

Once installed, you can publish the package configuration:

```
php artisan vendor:publish --tag=core-foundation
php artisan vendor:publish --tag=core-foundation-server-timing
```

Quick Start
-----------

[](#quick-start)

CoreFoundation provides interactive scaffolding to rapidly generate compliant modules.

```
php artisan core:make Order
```

This generates your Model, Factory, Repository, Service, Controller, Requests, Resource, DTO, Policy, Observer, Provider, and Feature Test – properly wired and ready to use.

Usage
-----

[](#usage)

For detailed usage instructions, guidelines on writing base classes, and architectural documentation, please refer to the official documentation.

[Read the Full Documentation](https://core-foundation-doc.rupeshstha.com.np/)

### Testing

[](#testing)

```
composer test
```

### Code Quality Analysis

[](#code-quality-analysis)

Analyze your project's PHP method complexity and code smell scores using the built-in analyzer:

```
php artisan core:analyse
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Rupesh Shrestha](https://github.com/rupeshstha)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance93

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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 ~359 days

Total

3

Last Release

44d ago

PHP version history (2 changes)0.0.1PHP ^8.1|^8.2

0.0.2PHP ^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/17748bd2229ba5d79c1d9a8f43d04c80de776ec285de438ef233442939ce6489?d=identicon)[rupeshstha](/maintainers/rupeshstha)

---

Top Contributors

[![rupeshstha](https://avatars.githubusercontent.com/u/46959961?v=4)](https://github.com/rupeshstha "rupeshstha (171 commits)")

---

Tags

api-based-appapi-corebase-for-apicore-foundationlaravel-apilaravel-api-baselaravel-api-boilerplatelaravel-api-foundationapilaraveloctanerepository patterndtostarter-kitCore Foundationmodular-monolithrupeshstha

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3365.5M359](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.1k6.4M362](/packages/laravel-ai)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.4M29](/packages/yajra-laravel-oci8)[api-platform/laravel

API Platform support for Laravel

58190.1k22](/packages/api-platform-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.5k](/packages/forjedio-inertia-table)

PHPackages © 2026

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