amphp/serialization
AMPHP serialization tools for IPC and storage in PHP. Provides a Serializer interface with JSON, native PHP serialize/unserialize, and passthrough implementations, plus optional payload compression via a wrapping serializer.
Architecture fit:
amphp/parallel, amphp/byte-stream). Its strengths—native PHP object serialization, compression for IPC, and fiber compatibility—are irrelevant for Laravel’s core use cases (e.g., JSON APIs, Eloquent, queues).json_encode, serialize) lack compression and native object support, but this package does not integrate with Laravel’s IPC layers (e.g., queues, cache drivers).Illuminate\Bus\Queueable).Illuminate\Cache\Repository).Integration feasibility:
amphp/byte-stream, amphp/parallel). Example:
$serializer = new CompressingSerializer(new NativeSerializer());
$payload = $serializer->serialize(['task' => $closure, 'data' => $resource]);
#[Override] conflicts).Technical risk:
NativeSerializer uses PHP’s unserialize(), which is unsafe for untrusted data. No built-in safeguards (e.g., whitelisting, sandboxing).#[Override] may conflict with Laravel’s attributes (e.g., #[Cacheable]). No PHP 8.x support confirmed, risking serialization failures during upgrades.SerializationException for unsupported types).@mathroc) has no Laravel experience, limiting future support.CompressingSerializer) may not benefit small payloads (e.g., API responses) and adds CPU overhead.Key questions:
json_encode, Redis::compress(), serialize) or existing packages (e.g., spatie/array-to-object)?NativeSerializer be isolated from untrusted data (e.g., user input in IPC)? Are there whitelists or validation layers?#[Override] work with Laravel’s attributes (e.g., #[Cacheable])? If not, what’s the upgrade cost to support them?SerializationException be caught and retried in async contexts (e.g., queue workers, cache)?JsonSerializer)?json_encode, serialize) or existing packages (e.g., spatie/array-to-object, symfony/serializer) achieve the same goals with lower risk?Stack fit:
amphp/parallel.amphp/byte-stream.Illuminate\Bus\Queueable relies on json_encode/json_decode.serialize/unserialize with custom handlers.json_encode for API responses and serialize for replication.#[Override]).Migration path:
amphp/parallel, amphp/byte-stream).amphp/serialization where it provides clear benefits (e.g., compression).JsonSerializer on failure).NativeSerializer for untrusted data.Compatibility:
amphp/parallel, amphp/byte-stream, and fiber-based workflows.#[Override] conflicts).NativeSerializer).Sequencing:
symfony/serializer).Maintenance:
How can I help you explore Laravel packages today?