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

Cloud Bundle Laravel Package

aspose/cloud-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require aspose/cloud-bundle:~0.3
    

    Update AppKernel.php to register the bundle:

    new Aspose\Bundle\CloudBundle\AsposeCloudBundle(),
    
  2. Configuration: Add credentials to config.yml:

    aspose_cloud:
        url: http://api.aspose.com/v1.1
        app:
            sid: your_client_id
            key: your_client_secret
            outputLocation: "%kernel.cache_dir%/aspose_cloud/"
    
  3. First Use Case: Convert a Word document to PDF in a controller:

    use Symfony\Component\HttpFoundation\Response;
    
    public function convertDocumentAction()
    {
        $app = $this->get('aspose.app');
        $wordConverter = $this->get('aspose.wordsconverter');
    
        $wordConverter->setFilename('/path/to/input.docx')
                      ->setFormat('pdf')
                      ->convert();
    
        return new Response('Conversion complete!');
    }
    

Implementation Patterns

Common Workflows

  1. File Conversion: Use service IDs like aspose.wordsconverter, aspose.slidesconverter, or aspose.spreadsheetconverter for format conversions.

    $converter = $this->get('aspose.wordsconverter');
    $converter->setFilename('/input.docx')
              ->setFormat('pdf')
              ->setOutputPath('/output.pdf')
              ->convert();
    
  2. Batch Processing: Loop through files and convert them sequentially:

    $files = ['file1.docx', 'file2.docx'];
    foreach ($files as $file) {
        $converter = $this->get('aspose.wordsconverter');
        $converter->setFilename($file)
                  ->setFormat('pdf')
                  ->convert();
    }
    
  3. Integration with Forms: Handle file uploads and conversions in a Symfony form:

    // Controller
    public function uploadAndConvertAction(Request $request)
    {
        $file = $request->files->get('document');
        $converter = $this->get('aspose.wordsconverter');
        $converter->setFilename($file->getPathname())
                  ->setFormat('pdf')
                  ->convert();
        return $this->render('success.html.twig');
    }
    
  4. Dependency Injection: Inject services directly into controllers or services:

    class DocumentService
    {
        private $wordConverter;
    
        public function __construct($wordConverter)
        {
            $this->wordConverter = $wordConverter;
        }
    
        public function processDocument($filePath)
        {
            $this->wordConverter->setFilename($filePath)
                                ->setFormat('pdf')
                                ->convert();
        }
    }
    

Gotchas and Tips

Pitfalls

  1. Authentication Errors:

    • Ensure sid and key in config.yml are correct and match your Aspose Cloud credentials.
    • Verify the API URL (aspose_cloud.url) is accurate (e.g., http://api.aspose.com/v1.1 for production).
  2. Output Location:

    • If outputLocation is not set or invalid, conversions may fail silently. Defaults to %kernel.cache_dir%/aspose_cloud/.
    • Ensure the directory is writable by the web server.
  3. File Paths:

    • Use absolute paths for setFilename() and setOutputPath() to avoid issues with relative paths.
    • Validate file existence before conversion to avoid errors.
  4. Rate Limits:

    • Aspose Cloud APIs have rate limits. Handle exceptions like Aspose\Cloud\Sdk\Exception\ApiException gracefully:
      try {
          $converter->convert();
      } catch (ApiException $e) {
          $this->addFlash('error', 'Conversion failed: ' . $e->getMessage());
      }
      

Debugging Tips

  1. Enable Verbose Logging: Configure the SDK to log requests/responses:

    aspose_cloud:
        debug: true
    

    Logs will appear in var/log/dev.log (Symfony default).

  2. Check Response Status: Inspect the response object for errors:

    $response = $converter->convert();
    if (!$response->isSuccess()) {
        throw new \RuntimeException($response->getErrorMessage());
    }
    
  3. Test with Small Files: Start with small files (e.g., <1MB) to rule out network or timeout issues.

Extension Points

  1. Custom Services: Extend the bundle to add new converters or modify existing ones:

    // services.yml
    services:
        aspose.custom_converter:
            class: AppBundle\Service\CustomConverter
            arguments: ['@aspose.app']
    
  2. Event Listeners: Trigger actions post-conversion (e.g., send email notifications):

    // src/AppBundle/EventListener/ConversionListener.php
    class ConversionListener
    {
        public function onConversionSuccess(ConversionEvent $event)
        {
            // Send email or log success
        }
    }
    
  3. Override Configuration: Dynamically override settings in runtime:

    $app = $this->get('aspose.app');
    $app->setOutputLocation('/custom/path/');
    
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.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui