sierratecnologia/pedreiro
Composer 安装命令:
composer require sierratecnologia/pedreiro
包简介
:package_description
README 文档
README
Pedreiro is a comprehensive Laravel package (≥5.5) that provides a powerful CRUD (Create, Read, Update, Delete) form framework and admin panel infrastructure. It's designed as a quick, non-intrusive tool that dramatically reduces the time spent building admin interfaces while maintaining flexibility and extensibility.
Features
- Complete CRUD System: Automatic generation of Create, Read, Update, Delete operations
- 20+ Form Field Types: Text, Number, Date, Image, Select, RichText, Markdown, and many more
- Relationship Handling: Seamless management of BelongsTo and ManyToMany relationships
- Data Export: Built-in CSV and Excel export capabilities
- AdminLTE Integration: Professional admin theme with customizable layouts
- DataTables Support: Fast, searchable, sortable data tables out of the box
- Multiple Sections: Organize your admin panel into Painel, Master, Admin, and Rica sections
- Validation System: Model-level validation with automatic form error handling
- Authorization: Policy-based access control for secure admin operations
- Localization: Multi-language support with locale-specific data
- Asset Management: Integrated asset pipeline with minification support
- Extensible Architecture: Easy to customize through traits, service providers, and handlers
Requirements
- PHP 7.2 or higher (PHP 8.0+ supported)
- Laravel 5.5 or higher
- Composer
Installation
Install the package via Composer:
composer require sierratecnologia/pedreiro
The package will automatically register its service provider through Laravel's package discovery.
Publish Configuration
Publish the package configuration and assets:
# Publish configuration files php artisan vendor:publish --provider="Pedreiro\PedreiroServiceProvider" --tag=config # Publish views (optional, for customization) php artisan vendor:publish --provider="Pedreiro\PedreiroServiceProvider" --tag=views # Publish assets php artisan vendor:publish --provider="Pedreiro\PedreiroServiceProvider" --tag=assets # Publish language files php artisan vendor:publish --provider="Pedreiro\PedreiroServiceProvider" --tag=lang
Run Migrations
Run the package migrations to create necessary database tables:
php artisan migrate
Configuration
The main configuration file is located at config/pedreiro.php. Key options include:
return [ // Base layout for admin pages 'blade_layout' => 'layouts.app', // Section name for content injection 'blade_section' => 'content', // Use FontAwesome icons in buttons 'button_icons' => true, ];
Usage
Basic CRUD Controller
Create a controller that uses the CrudController trait:
<?php namespace App\Http\Controllers\Admin; use App\Models\Post; use Pedreiro\CrudController; use Illuminate\Http\Request; use App\Http\Controllers\Controller; class PostController extends Controller { use CrudController; protected $model = Post::class; protected $views = [ 'index' => 'admin.posts.index', 'create' => 'admin.posts.create', 'edit' => 'admin.posts.edit', ]; }
Model Configuration
Extend the Pedreiro base model for enhanced functionality:
<?php namespace App\Models; use Pedreiro\Models\Base; class Post extends Base { protected $fillable = ['title', 'content', 'author_id', 'published_at']; // Define validation rules public $rules = [ 'title' => 'required|max:255', 'content' => 'required', ]; // Define admin-specific attributes public function getAdminTitleAttribute() { return $this->title; } public function getAdminThumbAttribute() { return $this->featured_image; } }
Form Fields
Define form fields for your model:
// In your controller or form builder $fields = [ [ 'name' => 'title', 'type' => 'text', 'label' => 'Post Title', ], [ 'name' => 'content', 'type' => 'richtext', 'label' => 'Content', ], [ 'name' => 'author_id', 'type' => 'select', 'label' => 'Author', 'relationship' => 'author', ], [ 'name' => 'published_at', 'type' => 'datetime', 'label' => 'Publish Date', ], ];
Available Field Types
Pedreiro supports 20+ field types:
- Text Inputs:
text,textarea,password,email,hidden - Numeric:
number - Selection:
select,select_multiple,checkbox,multiple_checkbox,radio - Date/Time:
date,time,datetime,timestamp - Files:
file,image,multiple_images,media_picker - Rich Content:
richtext,markdown,code_editor - Advanced:
color,coordinates,key_value_json
Routes
Define your admin routes:
Route::group(['prefix' => 'admin', 'middleware' => ['web', 'auth']], function () { Route::resource('posts', 'Admin\PostController'); });
Views
Pedreiro provides default views built with Bootstrap 3/4 and AdminLTE. You can customize them by publishing and modifying:
php artisan vendor:publish --provider="Pedreiro\PedreiroServiceProvider" --tag=views
The views include classes for popular JavaScript libraries:
- select2: Applied to select inputs
- datepicker: Applied to date inputs
- data-table: Applied to index view tables
Quality Tools Configuration
Pedreiro includes comprehensive code quality tools to maintain high standards.
PHPUnit
Run tests with:
composer test # With coverage composer test-coverage
Configuration: phpunit.xml.dist
PHP CS Fixer
Format code automatically:
composer format
Configuration: .php_cs.dist
Psalm
Static analysis with Psalm:
composer psalm
Configuration: psalm.xml
PHPStan
Static analysis with PHPStan:
./vendor/bin/phpstan analyse
Configuration: phpstan.neon
GrumPHP
Git hooks for automated quality checks are configured in grumphp.yml. GrumPHP runs automatically on:
- Pre-commit: Checks file size, commit message format, blacklisted keywords
- Pre-push: Runs Psalm analysis
To skip hooks (not recommended):
git commit --no-verify
GitHub Actions Workflows
The package includes GitHub Actions workflows for continuous integration:
- Tests: Runs PHPUnit tests on PHP 7.4, 8.0, 8.1 with Laravel 8.x and 9.x
- PHP CS Fixer: Automatically fixes code style issues
- Psalm: Runs static analysis on PHP code changes
- PHPStan: Runs additional static analysis
Advanced Features
Data Export
Export data to CSV or Excel:
use Pedreiro\Http\Requests\ExportModelRequest; public function export(ExportModelRequest $request) { return $this->exportData($request); }
Relationship Management
Handle relationships in forms:
// BelongsTo relationship [ 'name' => 'category_id', 'type' => 'select', 'relationship' => 'category', 'relationship_field' => 'name', ] // ManyToMany relationship [ 'name' => 'tags', 'type' => 'select_multiple', 'relationship' => 'tags', 'relationship_field' => 'name', ]
Custom Form Field Handlers
Create custom field handlers by implementing HandlerInterface:
<?php namespace App\FormFields; use Pedreiro\Elements\FormFields\HandlerInterface; class CustomFieldHandler implements HandlerInterface { public function createInput($name, $label, $attributes = []) { // Return HTML for the input field } public function getValue($model, $name) { // Return the field value from the model } }
Menu System
Add custom menu items in your service provider:
use Pedreiro\Facades\Pedreiro; Pedreiro::menu()->add([ 'text' => 'My Custom Section', 'url' => '/admin/custom', 'icon' => 'fas fa-cog', ]);
Testing
Run the test suite:
composer test
The package includes comprehensive tests covering:
- CRUD operations
- Form generation
- Relationship handling
- Data export (CSV/Excel)
- Localization
- File uploads
- Validation
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Development Setup
- Clone the repository
- Install dependencies:
composer install - Run tests:
composer test - Check code style:
composer format - Run static analysis:
composer psalm
Documentation
Detailed documentation is available:
Changelog
Please see CHANGELOG.md for release notes and version history.
License
The MIT License (MIT). Please see LICENSE.md for more information.
About SierraTecnologia
Pedreiro is maintained by SierraTecnologia and created by Ricardo Sierra. It's part of a comprehensive ecosystem of Laravel packages designed to accelerate development:
- Muleta: Utility library for common Laravel operations
- CrudMaker: Code generator for CRUD applications
- Former: Advanced form builder
- Changelog: Version management and release notes
For more information, visit:
- Website: https://ricasolucoes.com.br
- GitHub: https://github.com/SierraTecnologia
sierratecnologia/pedreiro 适用场景与选型建议
sierratecnologia/pedreiro 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 579 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「SierraTecnologia」 「pedreiro」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sierratecnologia/pedreiro 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sierratecnologia/pedreiro 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sierratecnologia/pedreiro 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SierraTecnologia common support helpers, contracts, and traits required by various SierraTecnologia packages. Validator functionality, and basic controller included out-of-the-box.
Recursos para GeoLocalização
Sierratecnologia Cashier provides an expressive, fluent interface to SierraTecnologia's subscription billing services.
Integrations de Serviços
MediaManager de Arquivos
Fabrica de Projetos
统计信息
- 总下载量: 579
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 10
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-08