chrisjk123/laravel-blogger
Composer 安装命令:
composer require chrisjk123/laravel-blogger
包简介
blog package
README 文档
README
Table of Contents
Introduction
This package is a blogging database with maxed out models, migrations and seeders to help get you setup. After the package is installed the only thing you have to do is add the HasPosts trait to an Eloquent model to associate the users.
Here are some code examples:
// Alias namespace path: // Chriscreates\Blog\Post // Chriscreates\Blog\Category // Chriscreates\Blog\Tag // Chriscreates\Blog\Comment // Search by the short whereCategories method OR use whereCategory() and specify the field $results = Post::whereCategories($categories = null)->get(); $results = Post::whereCategory($field, $operator, $value)->get(); // Search by Category ID OR IDs $results = Post::whereCategories(1)->get(); $results = Post::whereCategory('id', 1)->get(); ---------- $results = Post::whereCategories([3, 6, 7])->get(); $results = Post::whereCategory('id', [3, 6, 7])->get(); // Search by Category name OR names $results = Post::whereCategories('Izabella Bins II')->get(); $results = Post::whereCategory('name', 'Izabella Bins II')->get(); ---------- $results = Post::whereCategories(['Izabella Bins II', 'Osborne Fay'])->get(); $results = Post::whereCategory('name', ['Izabella Bins II', 'Osborne Fay'])->get(); // Search by Category model or a Category Collection $category = Category::where('id', 7)->first(); $results = Post::whereCategories($category)->get(); ---------- $categories = Category::whereIn('id', [3, 6, 7])->get(); $results = Post::whereCategories($categories)->get(); // Search by related Post (tags or category) $post = Post::find(8); $results = Post::relatedByPostTags($post)->get(); ---------- $results = Post::relatedByPostCategory($post)->get(); // Search by published Posts only Post::published()->get(); ---------- Post::publishedLastMonth()->get(); ---------- Post::publishedLastWeek()->get(); // Search by unpublished Posts only Post::notPublished()->get(); // Search by scheduled Posts only Post::scheduled()->get(); // Search by drafted Posts only Post::draft()->get(); // Order by latest published Post::orderByLatest()->get();
Requirements
This package requires Laravel 5.8 or higher, PHP 7.2 or higher and a database that supports json fields and MySQL compatible functions.
Installation
Note: Laravel Blogger requires you to have user authentication in place prior to installation. For Laravel 5.* based projects run the
make:authArtisan command. For Laravel 6.* based projects please see the official guide to get started.
You can install the package via composer:
composer require chrisjk123/laravel-blogger
Publish the primary configuration file using the blog:install Artisan command:
php artisan blog:install
This is the contents of the published config file, if your User class is
within a different directory or has a different primary key it can be changed here.
/* |-------------------------------------------------------------------------- | User relations |-------------------------------------------------------------------------- | | This is the default path to the User model in Laravel and primary key. | You are free to change this path to anything you like. | */ 'user' => [ 'user_class' => \App\User::class, 'user_key_name' => 'id', ],
Optionally you can follow the artesaos/seotools guide to help provide some common SEO techniques for your public frontend:
{{-- Within the head of your app.blade.php file --}}
{!! SEOMeta::generate() !!}
{!! OpenGraph::generate() !!}
Testing
Run the tests with:
composer test
Usage
All you have to do is add the HasPosts to your User model to get started.
namespace App; use Chriscreates\Blog\Traits\User\HasPosts; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; class User extends Authenticatable { use Notifiable, HasPosts; // ... } // Retrieve the posts created by the user(s) $user->posts; // Retrieve the comments created by the guest/user(s) $user->comments;
{{-- Print the published post markdown content --}}
{!! $post->parsed_markdown !!}
Furthermore, in the configuration file, the default is set to true for allowing both user and public commenting on posts is set here.
/* |-------------------------------------------------------------------------- | Post commenting options |-------------------------------------------------------------------------- | | The default for commenting on posts is enabled, as well as guest | commenting. Feel free to change these conditions to false. | */ 'posts' => [ 'allow_comments' => true, 'allow_guest_comments' => true, ],
You can get setup quickly by using the blog:setup Artisan command.
This publishes the routes, controllers and views. Optionally you can seed the
database with factory() data by specifying the data --data option.
php artisan blog:setup --data
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security related issues, please email christopherjk123@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
chrisjk123/laravel-blogger 适用场景与选型建议
chrisjk123/laravel-blogger 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 29 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「blogger」 「blog」 「laravel」 「chrisjk123」 「laravel-blogger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 chrisjk123/laravel-blogger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chrisjk123/laravel-blogger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 chrisjk123/laravel-blogger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel package for opinionated blog implementation
Import an RSS-feed into blog
Faker provider for NumberNine CMS
simple and elegant blog platform powered by Laravel
A blog module for AsgardCMS.
Alfabank REST API integration
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-12-30