Weave 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

Parse Laravel Package

coderockr/parse

PHP package for parsing and extracting data from strings and text sources with a simple API. Useful for building lightweight parsers, reading structured patterns, and turning raw input into usable values in Laravel or any PHP project.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require coderockr/parse
    

    Add the package to config/app.php under providers if using Laravel’s service container.

  2. Configuration Publish the config file:

    php artisan vendor:publish --provider="Coderockr\Parse\ParseServiceProvider"
    

    Update .env with your Parse credentials:

    PARSE_APP_ID=your_app_id
    PARSE_REST_API_KEY=your_rest_key
    PARSE_MASTER_KEY=your_master_key (if needed)
    
  3. First Use Case: Querying Objects

    use Coderockr\Parse\ParseClient;
    
    $client = app(ParseClient::class);
    $results = $client->get('GameScore')->query()->get();
    

Implementation Patterns

Core Workflows

  1. CRUD Operations

    • Create:
      $client->get('GameScore')->create([
          'score' => 100,
          'playerName' => 'John',
      ]);
      
    • Read:
      $client->get('GameScore')->get('objectId');
      
    • Update:
      $client->get('GameScore')->update('objectId', ['score' => 200]);
      
    • Delete:
      $client->get('GameScore')->delete('objectId');
      
  2. Querying with Conditions

    $query = $client->get('GameScore')
        ->query()
        ->equalTo('playerName', 'John')
        ->greaterThan('score', 50)
        ->get();
    
  3. File Operations

    $file = $client->getFile('profilePic.jpg', file_get_contents('path/to/file'));
    $file->save();
    
  4. Cloud Code Execution

    $client->executeCloudFunction('myFunction', ['param' => 'value']);
    

Integration Tips

  • Laravel Facades: Extend the package with a facade for cleaner syntax:

    // app/Providers/AppServiceProvider.php
    use Illuminate\Support\Facades\Facade;
    
    Facade::register('Parse', function () {
        return app('parse');
    });
    

    Usage:

    Parse::get('GameScore')->query()->get();
    
  • Middleware for Auth: Protect routes using Parse’s session tokens:

    Route::middleware('parse.auth')->group(function () {
        // Protected routes
    });
    
  • Event Listeners: Subscribe to Parse webhooks for real-time updates:

    // routes/web.php
    Route::post('/parse-webhook', 'ParseWebhookController@handle');
    

Gotchas and Tips

Pitfalls

  1. Master Key Exposure

    • Avoid hardcoding PARSE_MASTER_KEY in environment files for production. Use Laravel’s secure secrets or a secrets manager.
  2. Rate Limiting

    • Parse enforces rate limits. Cache frequent queries or use background jobs for heavy operations.
  3. Query Complexity

    • Deeply nested queries (e.g., include() with multiple relations) may fail silently. Test thoroughly with small datasets.
  4. File Handling

    • Large files (>20MB) require chunked uploads. Use ParseFile::saveWithChunks() if needed.

Debugging

  • Enable Debug Mode:

    $client = app(ParseClient::class)->setDebug(true);
    

    Logs will appear in storage/logs/parse.log.

  • HTTP Errors: Parse returns HTTP errors (e.g., 404 for missing objects). Use Laravel’s try-catch with Coderockr\Parse\Exceptions\ParseException:

    try {
        $client->get('NonExistentClass')->get('fakeId');
    } catch (ParseException $e) {
        Log::error($e->getMessage());
    }
    

Extension Points

  1. Custom Classes Extend Coderockr\Parse\ParseObject for domain-specific logic:

    class User extends ParseObject
    {
        public function getFullName()
        {
            return $this->get('firstName') . ' ' . $this->get('lastName');
        }
    }
    
  2. Hooks for Lifecycle Events Use Laravel’s observers or model events to trigger actions on Parse object changes:

    // app/Providers/AppServiceProvider.php
    ParseObject::observe('GameScore', function ($model) {
        if ($model->wasRecentlyCreated) {
            // Send notification
        }
    });
    
  3. Batch Operations For bulk updates, use ParseObject::updateAll():

    ParseObject::updateAll('GameScore', ['score' => 0], ['playerName' => 'John']);
    
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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin