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

Support Laravel Package

corepine/support

A small collection of Laravel/PHP support utilities from Corepine, providing reusable helpers and common building blocks to simplify everyday application code and package development.

View on GitHub
Deep Wiki
Context7

Getting Started

First Steps

  1. Installation

    composer require corepine/support
    
    • Check composer.json for Laravel compatibility (if version-agnostic, test against your Laravel version).
    • No publisher needed—just require the package.
  2. Core Features

    • Helper Functions: Scan the src/Support/helpers.php (or equivalent) for static utility methods (e.g., str(), arr(), obj() wrappers).
    • Service Provider: Look for SupportServiceProvider in config/support.php (if provided) for bootstrapped bindings or macros.
    • Facade: If available (e.g., Support::camel_case($string)), alias it in config/app.php.
  3. First Use Case

    use Corepine\Support\Facades\Support; // or \Corepine\Support\helpers;
    
    // Example: String manipulation
    $snakeCase = Support::snake_case('CamelCaseString');
    
    // Example: Array helpers
    $flattened = Support::arr()->flatten($nestedArray);
    

Implementation Patterns

Common Workflows

  1. Replacing Native PHP Functions

    • Replace strtolower() with Support::str()->lower($string) for consistency.
    • Example:
      $cleaned = Support::str()
          ->trim($input)
          ->slugify()
          ->value();
      
  2. Collection/Array Manipulation

    • Chain methods like Laravel Collections but for arrays:
      $result = Support::arr($array)
          ->pluck('key')
          ->filter(fn($val) => $val > 10)
          ->toArray();
      
  3. Object Utilities

    • Serialize/deserialize objects or extract properties:
      $data = Support::obj($model)->toArray();
      $class = Support::obj()->getClass($object);
      
  4. Macros/Extensions

    • Extend core classes (if the package supports it):
      Support::extend('str', function ($str) {
          return $str->append('!');
      });
      
  5. Integration with Laravel

    • Service Container: Bind custom resolvers:
      $this->app->bind('custom.helper', function () {
          return new \Corepine\Support\CustomHelper();
      });
      
    • Blade Directives: Register helpers for views:
      Support::blade()->directive('camel', function ($expr) {
          return "<?php echo \\Corepine\Support\\Str::camel({$expr}); ?>";
      });
      
  6. Testing

    • Mock static helpers with partial mocking:
      $mock = $this->partialMock(Support::class, ['snake_case']);
      $mock->shouldReceive('snake_case')->andReturn('test');
      

Gotchas and Tips

Pitfalls

  1. Static vs. Instance Methods

    • If the package mixes static (Support::str()->lower()) and instance (new Support()->lower()) styles, stick to one to avoid confusion.
    • Tip: Wrap static calls in a facade for better testability.
  2. Laravel Version Conflicts

    • Test with your Laravel version (e.g., laravel/framework:^10.0). If undocumented, check for:
      • Illuminate\Support method overrides (e.g., Str::macro() conflicts).
      • Composer platform checks (--ignore-platform-reqs may hide issues).
  3. Performance Overhead

    • Chained methods (e.g., Support::str()->lower()->upper()) may create intermediate objects.
    • Tip: Use ->value() early to release memory:
      $result = Support::str($input)->lower()->value(); // Force execution
      
  4. Namespace Collisions

    • If the package uses Support as a facade/class name, ensure it doesn’t clash with:
      • Custom app/Support/ directories.
      • Other packages like spatie/laravel-support.
  5. Undocumented Features

    • Some methods may rely on hidden config (e.g., config/support.php).
    • Tip: Dump the config after installation:
      dd(config('support'));
      

Debugging Tips

  1. Method Introspection

    • Use get_declared_methods() to list available methods:
      $methods = get_declared_methods(\Corepine\Support\Str::class);
      print_r($methods);
      
  2. Error Handling

    • Wrap calls in try-catch for undefined methods:
      try {
          Support::str()->unknownMethod();
      } catch (\BadMethodCallException $e) {
          Log::error($e->getMessage());
      }
      
  3. Configuration Quirks

    • If the package uses config/support.php, merge defaults:
      $config = config('support', [
          'default_locale' => 'en_US',
      ]);
      

Extension Points

  1. Custom Helpers

    • Add to app/Helpers/Support.php and autoload:
      // composer.json
      "autoload": {
          "files": ["app/Helpers/Support.php"]
      }
      
      // app/Helpers/Support.php
      if (!function_exists('custom_helper')) {
          function custom_helper($input) {
              return \Corepine\Support\Str::of($input)->upper();
          }
      }
      
  2. Macro System

    • Extend core classes (if supported):
      \Corepine\Support\Str::macro('customMacro', function ($str) {
          return $str . ' [custom]';
      });
      
  3. Event Listeners

    • Hook into package events (if documented):
      Event::listen('support.helper.called', function ($payload) {
          Log::info('Helper called:', $payload);
      });
      
  4. Testing Extensions

    • Override methods in tests:
      \Corepine\Support\Str::shouldReceive('snake_case')
          ->once()
          ->andReturn('overridden');
      
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