Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Core Bundle Laravel Package

darkanakin41/core-bundle

View on GitHub
Deep Wiki
Context7
## Getting Started
This package is in its **v1.0.0-beta** stage, meaning it is newly released and primarily focused on foundational setup. To begin:

1. **Installation**: Add the package via Composer:
   ```bash
   composer require vendor/package-name

Publish the package's configuration (if applicable) with:

php artisan vendor:publish --provider="Vendor\PackageName\PackageServiceProvider"
  1. Pipeline Setup: The package introduces a quality-check pipeline as its core feature. Review the config/package-name.php file for pipeline configuration (e.g., validation rules, hooks, or middleware). The default setup likely includes manual validation logic—check the app/Providers/PackageServiceProvider.php for pipeline registration.

  2. First Use Case: Run the pipeline manually to validate a basic workflow:

    use Vendor\PackageName\Facades\Pipeline;
    
    $result = Pipeline::run(function ($payload) {
        // Your logic here (e.g., data transformation, validation)
        return $payload;
    }, ['input_data' => 'example']);
    

    Verify output via dd($result) or logging.

  3. Documentation: Since this is a beta, consult the package's README.md for setup instructions and basic examples. The release notes hint at manual testing as the primary validation method—expect minimal automated documentation.


Implementation Patterns

Core Workflow: Pipeline Execution

The package revolves around a pipeline system for processing data with quality checks. Common patterns include:

  1. Chaining Validators/Middleware: Define stages in the pipeline using closures or callable classes. Example:

    Pipeline::run(function ($data) {
        // Stage 1: Sanitize input
        return sanitize($data);
    })
    ->then(function ($data) {
        // Stage 2: Validate structure
        return validateStructure($data);
    });
    
  2. Reusable Pipeline Definitions: Store pipeline configurations in the config/package-name.php file for reuse across the application. Example:

    'pipelines' => [
        'user_registration' => [
            'sanitize',
            'validate_email',
            'check_blacklist',
        ],
    ],
    

    Then execute via:

    Pipeline::runConfig('user_registration', $userData);
    
  3. Integration with Laravel Services:

    • Form Requests: Use the pipeline to validate incoming requests:
      public function validate(Request $request) {
          $validated = Pipeline::run(function ($input) use ($request) {
              return $request->validate($input);
          }, $request->all());
      }
      
    • Events: Trigger pipelines on event dispatch:
      event(new UserRegistered($user));
      // Pipeline runs automatically if configured in `EventServiceProvider`.
      
  4. Testing Pipelines: Since the package lacks unit tests (as noted in release notes), manually test each stage:

    $this->assertEquals(
        ['sanitized' => true],
        Pipeline::run(fn($d) => ['sanitized' => true], ['raw' => 'data'])
    );
    

Quality Checks

The pipeline includes manual validation as a core feature. Leverage this for:

  • Data Sanitization: Strip or escape user input before processing.
  • Business Logic Validation: Enforce rules (e.g., "price must be positive").
  • Third-Party API Calls: Validate responses before storing them.

Gotchas and Tips

Pitfalls

  1. Beta Stage Limitations:

    • No Automated Tests: The release notes mention "TBT: Unit testing," implying tests are pending. Rely on manual validation for now.
    • Undocumented APIs: Assume public methods like Pipeline::run() are stable, but avoid deep integration until v1.0.0.
    • Configuration Overrides: If publishing config, ensure your config/package-name.php merges correctly with defaults to avoid silent failures.
  2. Pipeline Execution Quirks:

    • Error Handling: Pipelines may halt on failures. Use try-catch or return false to handle errors gracefully:
      $result = Pipeline::run(function ($data) {
          if (invalid($data)) return false;
          return $data;
      }, $input);
      if ($result === false) { /* Handle error */ }
      
    • State Mutation: Pipelines pass data by value. Modify a copy to avoid unintended side effects:
      Pipeline::run(function ($data) {
          $data['processed'] = true; // Affects only this stage
          return $data;
      });
      
  3. Performance:

    • Avoid heavy computations in pipelines. Use them for lightweight validation/transformation.
    • Cache pipeline configurations if reused frequently (e.g., in a BootstrapServiceProvider).

Tips

  1. Extending the Pipeline:

    • Custom Stages: Create callable classes for reusable logic:
      class SanitizeStage {
          public function __invoke($data) { return filter_var($data, FILTER_SANITIZE_STRING); }
      }
      Pipeline::run(new SanitizeStage(), $data);
      
    • Middleware-Style Pipelines: Mimic Laravel middleware by returning $next($request):
      Pipeline::run(function ($request) {
          return function ($next) {
              return $next($request)->then(function ($response) {
                  // Post-processing
                  return $response;
              });
          };
      });
      
  2. Debugging:

    • Log Pipeline Output: Add logging to each stage:
      Pipeline::run(function ($data) {
          \Log::debug('Pipeline stage data:', $data);
          return $data;
      });
      
    • Dump Pipeline Config: Verify your config/package-name.php is loaded correctly:
      \Log::info('Pipeline configs:', config('package-name.pipelines'));
      
  3. Testing Strategy:

    • Manual Test Suite: Since unit tests are pending, document your manual test cases in a TESTING.md file. Example:
      1. Input: ['email' => 'test@example.com'] → Output: ['valid' => true]
      2. Input: ['email' => 'invalid'] → Output: ['valid' => false, 'error' => '...']
      
    • Feature Tests: Use Laravel's HTTP tests to validate pipeline integration:
      $response = $this->post('/register', ['email' => 'test@example.com']);
      $response->assertSessionHas('pipeline_result');
      
  4. Future-Proofing:

    • Watch for v1.0.0: The beta implies breaking changes are possible. Plan to update your implementation when stable.
    • Contribute: If you rely heavily on this package, consider contributing tests or documentation to the repo.

---
NO_UPDATE_NEEDED was not applicable here due to the beta release introducing foundational features warranting a full assessment.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware