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 Laravel Package

beloop/core

Core component of the Beloop LMS suite: shared foundations used by other Beloop components and bundles built on Symfony. MIT licensed. Read-only split package—use the main beloop/components repository for issues, questions, and PRs.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Update Composer to ensure compatibility with PHP 7.2+:

    composer require beloop/core:^1.0 --with-all-dependencies
    

    Verify your PHP version (php -v) meets the 7.2+ requirement.

  2. Service Provider Register the provider in config/app.php:

    'providers' => [
        Beloop\Core\BeloopServiceProvider::class,
    ],
    
  3. Publish Config Publish the updated config file:

    php artisan vendor:publish --provider="Beloop\Core\BeloopServiceProvider" --tag="config"
    

    Review config/beloop.php for PHP 7.2+ optimizations.

  4. First Use Case Use the facade or container binding (if available):

    use Beloop\Core\Facades\Beloop;
    
    $result = Beloop::process('input', ['schema' => 'new_schema']); // Updated method signature
    

Implementation Patterns

Core Workflows

  1. PHP 7.2+ Features

    • Pattern: Leverage typed properties, nullable return types, or array/iterable support in newer PHP versions.
    • Example:
      $transformed = Beloop::transform(iterable $data): array;
      
  2. Schema Validation

    • Pattern: Define schemas in config/beloop.php with PHP 7.2+ syntax:
      'schemas' => [
          'new_schema' => [
              'fields' => [
                  'name' => ['type' => 'string', 'nullable' => true],
              ],
          ],
      ],
      
  3. Event Handling with PHP 7.2+

    • Pattern: Use modern event listeners with type hints:
      Event::listen(BeloopEvents::PROCESSED, function (ProcessedEvent $event) {
          Log::debug('Processed data:', $event->getData());
      });
      
  4. Middleware Integration

    • Pattern: Use middleware for request/response processing with PHP 7.2+ features:
      namespace App\Http\Middleware;
      
      use Beloop\Core\Beloop;
      use Closure;
      
      class BeloopMiddleware
      {
          public function __invoke($request, Closure $next): Response
          {
              $request->merge(['processed' => Beloop::sanitize($request->all())]);
              return $next($request);
          }
      }
      

Gotchas and Tips

Pitfalls

  1. PHP Version Mismatch

    • Error: FatalErrorException: Class 'Beloop\Core\Processor' not found or similar.
    • Fix: Ensure PHP 7.2+ is installed (php -v). Use a .php-version file or Docker if needed.
  2. Deprecated Features

    • Risk: Older Laravel versions (pre-5.8) may conflict with PHP 7.2+ changes.
    • Mitigation: Test with Laravel 5.8+ or upgrade your project.
  3. Undefined Methods

    • Issue: Methods like Beloop::debug() may not exist in v1.0.
    • Workaround: Use Log::debug() directly or check the src/ for alternatives.
  4. Config Changes

Debugging Tips

  1. Enable Strict Typing Add to composer.json for stricter checks:

    "config": {
        "platform-check": true,
        "preferred-install": "dist"
    }
    

    Then run:

    composer install --prefer-dist --no-dev
    
  2. Dump Processed Data Use PHP 7.2+ features for debugging:

    dd(Beloop::process($data, ['schema' => 'new_schema']));
    
  3. Check for Nullable Returns If a method returns ?array, handle null cases:

    $result = Beloop::fetchData();
    if ($result === null) {
        return response()->json(['error' => 'Data not found'], 404);
    }
    

Extension Points

  1. Custom Processors with PHP 7.2+ Extend core classes with typed properties:

    namespace App\Extensions;
    
    use Beloop\Core\Processor;
    
    class CustomProcessor extends Processor
    {
        public function __construct(private array $config) {}
    
        public function extraLogic(array $data): array
        {
            return array_merge($data, ['processed_at' => now()->toIso8601String()]);
        }
    }
    
  2. Add New Schemas with Type Safety Define schemas with strict typing in config/beloop.php:

    'schemas' => [
        'user' => [
            'fields' => [
                'id' => ['type' => 'int', 'required' => true],
                'email' => ['type' => 'string', 'format' => 'email'],
            ],
        ],
    ],
    
  3. Override Default Config Use PHP 7.2+ array merging in config/beloop.php:

    return array_merge([
        'debug' => env('BELOOP_DEBUG', false),
    ], config('beloop.custom', []));
    
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor