turahe / post
A package for managing posts.
Fund package maintenance!
turahe
wach.id/open-source/support-us
Requires
- php: ^8.2
- turahe/core: ^1.0
Requires (Dev)
- laravel/pint: ^1.18
- orchestra/testbench: ^9.6|^10.0
README
๐ Turahe Post
A powerful Laravel package for managing posts with rich content, markdown support, and comprehensive testing.
๐ Quick Start
composer require turahe/post
๐ฆ Installation
Step 1: Install Package
composer require turahe/post
Step 2: Publish Resources
php artisan vendor:publish --provider="Turahe\Post\PostServiceProvider"
Step 3: Run Migrations
php artisan migrate
Step 4: Done! ๐
Your post management system is ready to use.
โจ Features
Feature | Status | Description |
---|---|---|
๐ฏ Post Management | โ Ready | Create, update, and manage posts with ease |
๐ Content Support | โ Ready | Rich content with markdown conversion |
๐ Slug Generation | โ Ready | Automatic slug generation from titles |
๐๏ธ Soft Deletes | โ Ready | Safe deletion with data preservation |
๐ค User Stamps | โ Ready | Track who created and modified posts |
๐ Sorting | โ Ready | Flexible post ordering and sorting |
๐ข Publishing | โ Ready | Control post publication status |
๐ Multi-language | โ Ready | Support for different languages |
๐งช Comprehensive Testing | โ Ready | 21 tests with 79 assertions |
๐จ Code Quality | โ Ready | PSR-12 compliant with Laravel Pint |
๐ Quick Start
๐ Basic Usage
use Turahe\Post\Models\Post; // Create a post $post = Post::create([ 'title' => 'My First Post', 'subtitle' => 'A subtitle', 'description' => 'Post description', 'type' => 'post', ]); // Add content with markdown $post->setContents('# Hello World\n\nThis is **markdown** content.'); // Get formatted content echo $post->content; // HTML output echo $post->content_raw; // Raw markdown
๐ Content Management
// Get the latest content $content = $post->getContent(); // Get word count and read time echo $content->word_count; // Number of words echo $content->read_time['text']; // "2 minutes"
๐ข Publishing Posts
// Publish a post $post->update(['published_at' => now()]); // Get published posts $published = Post::published()->get(); // Get draft posts $drafts = Post::notPublished()->get();
๐ค Contributing
We welcome contributions! Please ensure:
๐ Requirements
- โ
Code Quality: Run
composer check
before submitting - โ Test Coverage: Maintain or improve test coverage
- โ Documentation: Update documentation as needed
๐งช Testing Guidelines
- Write tests for new features
- Ensure existing tests pass
- Aim for 90%+ code coverage
- Test both happy path and edge cases
๐ Coverage Requirements
- New Features: Must have 90%+ coverage
- Bug Fixes: Must include regression tests
- Refactoring: Must maintain existing coverage levels
๐ Coverage Reports
For detailed coverage analysis, see:
- ๐
COVERAGE_REPORT.md
- Comprehensive coverage analysis - ๐
coverage/index.html
- Visual HTML report - ๐
coverage.xml
- XML data for CI/CD
๐ ๏ธ Development
๐งช Testing
# Run the test suite composer test # Run tests with coverage composer test-coverage
๐จ Code Quality
# Check code style composer pint-test # Fix code style issues composer pint # Run all quality checks (code style + tests) composer check
๐ Code Coverage
# Run tests with coverage analysis $env:XDEBUG_MODE="coverage"; composer test-coverage
๐ Current Coverage: 46% overall (23/50 statements)
Component | Coverage | Status | Priority |
---|---|---|---|
โ Post Model | 100% | ๐ข Excellent | Maintain |
โ HasContents Trait | 92.9% | ๐ก Very Good | Improve |
โ Content Model | 0% | ๐ด Critical | Add Tests |
โ PostServiceProvider | 0% | ๐ด Critical | Add Tests |
๐ Requirements
Requirement | Version |
---|---|
PHP | ^8.2 |
Laravel | 9.x, 10.x, 11.x |
Database | MySQL, PostgreSQL, SQLite |
๐ CI/CD
This package uses GitHub Actions for continuous integration and deployment.
๐งช Continuous Integration
Feature | Description |
---|---|
๐งช Tests | Runs on PHP 8.2, 8.3, and 8.4 |
๐จ Code Quality | Checks code style using Laravel Pint |
๐ Security | Runs security audits on dependencies |
๐ Coverage | Generates and uploads coverage reports to Codecov |
๐ Automatic Releases
Feature | Description |
---|---|
๐ท๏ธ Trigger | Pushes to tags (e.g., v1.2.1 ) |
โก Process | Runs tests โ Creates GitHub release โ Publishes to Packagist |
๐ Requirements | Set PACKAGIST_USERNAME and PACKAGIST_TOKEN secrets |
๐ Automated Triggers
- โ
Push to
master
ormain
branches - โ
Pull requests to
master
ormain
branches - โ Tag pushes (triggers automatic release)
๐ Code Coverage Status
Component | Coverage | Status | Priority |
---|---|---|---|
โ Post Model | 100% | ๐ข Excellent | Maintain |
โ HasContents Trait | 92.9% | ๐ก Very Good | Improve |
โ Content Model | 0% | ๐ด Critical | Add Tests |
โ PostServiceProvider | 0% | ๐ด Critical | Add Tests |
๐ Overall Coverage: 46% (23/50 statements)
๐ฏ Coverage Goals
Goal | Target | Status |
---|---|---|
Target | 90%+ overall coverage | ๐ฏ In Progress |
Priority | Add tests for Content model and PostServiceProvider | ๐ Planned |
Maintenance | Keep Post model at 100% coverage | โ Maintained |
๐ License
This package is open-sourced software licensed under the MIT license.
๐ Support
Resource | Link |
---|---|
๐ Issues | GitHub Issues |
๐ Documentation | Coverage Report |
๐ CI/CD | GitHub Actions |
๐ฆ Packagist | Packagist Package |
๐ Changelog
๐ v1.2.0 (Latest)
Feature | Description |
---|---|
โจ CI/CD Pipeline | Comprehensive GitHub Actions workflow |
๐งช Multi-PHP Testing | Runs on PHP 8.2, 8.3, and 8.4 |
๐จ Code Quality | Laravel Pint integration |
๐ Security | Composer audit integration |
๐ Coverage | Xdebug reporting with detailed analysis |
๐ Authentication | Private repository support |
๐ฆ Packagist | Custom repository support |
๐ Auto Release | Automatic Packagist publishing on tag push |
๐ Reports | Detailed coverage analysis |
๐ Documentation | Comprehensive guides and examples |
๐ง Updates | Latest GitHub Actions versions |
๐ v1.1.0
Feature | Description |
---|---|
โจ Content Management | Rich content features |
๐ Markdown Support | Full markdown conversion |
๐ Analytics | Word count and read time calculations |
๐ v1.0.0
Feature | Description |
---|---|
๐ Initial Release | Basic package foundation |
โจ Post Management | Core post functionality |
๐ Slug Generation | Automatic slug creation |
๐๏ธ Soft Deletes | Safe data deletion |