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

Substrate Codec Php Laravel Package

gmajor/substrate-codec-php

PHP implementation of the Substrate SCALE codec for encoding and decoding Polkadot/Substrate data structures, with compact serialization for integers, strings, arrays, tuples, and custom types in PHP applications.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Verdict: A small, stateless, MIT-licensed SCALE encoder/decoder for PHP. It is a legitimate primitive, not a blockchain SDK — treat it as a low-risk leaf dependency that you must wrap, pin, and conformance-test, and assume you are the maintainer of last resort.

Architecture fit

  • Pure-function byte codec (encode/decode primitives, compact integers, Vec, tuples, structs, enums/Option/Result). No I/O, no globals, no framework coupling — trivially safe to place in the domain layer of a Laravel app.
  • It does not ship a Laravel service provider, config, facade, or typed DTOs. You will write the binding yourself (~1 file + one interface). That is cheap, but it means "Laravel ergonomics" are your deliverable, not the package's.
  • Correct placement is behind an anti-corruption interface (ScaleCodec), called by an RPC client layer, itself called by application services. Do not let gmajor\... types leak into domain or controller code.

Integration feasibility

  • Composer-installable, permissive license, narrow API surface — integration is days, not weeks, for encode/decode alone.
  • Scope gap to verify before committing: SCALE is only one of four things needed to talk to a Substrate node. Confirm whether the package also covers (a) blake2b-256/xxhash hashing required to hash an encoded call before signing, (b) SS58 address encode/decode, (c) runtime metadata (v14/v15) parsing and type registry, (d) any signing (sr25519/ed25519/ecdsa). If any are missing, they become separate dependencies or force read-only scope.

Technical risk

  • Numeric width: PHP has no native u128/u256; correct handling depends on ext-gmp/ext-bcmath and 64-bit builds. This is the most likely source of subtle production defects.
  • Untrusted input: length-prefixed Vec/Bytes decoding invites memory exhaustion and unbounded loops. Codec must enforce caps; verify it does.
  • Correctness confidence: 8 stars, 0 dependents, single maintainer = no ecosystem validation. Correctness rests entirely on whether parity-scale-codec golden vectors are in the test suite.
  • Provenance hygiene: package name (gmajor/substrate-codec-php) does not match the reviewed repository (php-scale-codec), and the reported release date (2026-03-30) is anomalous. Verify on Packagist that the installed package resolves to the audited commits, that tags are signed/immutable, and that semver is honored.

Key questions

  1. Does it include blake2b/xxhash hashing and SS58, or only the codec?
  2. Which Substrate metadata versions can it drive (v14, v15, both)?
  3. Are parity-scale-codec conformance vectors present, and do they run in CI?
  4. Which PHP versions and extensions are required; is 32-bit explicitly rejected?
  5. Are decode errors exceptions or sentinel returns, and are length prefixes bounded?
  6. Is there any typed/codegen path from metadata, or must call structures be hand-modelled per pallet?
  7. Who is the maintainer, what is the release cadence, and is there a documented fork/transfer path?

Integration Approach

Stack fit

  • Laravel 10/11/12 on PHP 8.1+ with ext-gmp and ext-bcmath available in the container image. Confirm the extensions in the Dockerfile before the first commit — not in staging.
  • Codec sits between your RPC transport (Laravel Http or Guzzle) and your signing/serialization service. Keep transport, codec, and signing as three separate collaborators so each is independently testable and replaceable.

Migration path

  • No incumbent to displace, so this is greenfield adoption, not migration.
  • If you currently hand-roll byte packing (pack('v'), pack('P'), manual hex concatenation) to read chain state, migrate in reverse order of risk: replace decoding first (read-only, failures are loud and non-destructive), then encoding of unsigned payloads, then signing.

Compatibility

  • Pin the exact version in composer.json and commit composer.lock. Do not accept floating ranges on a package with one maintainer and zero dependents.
  • Maintain an explicit compatibility matrix: PHP version × extension set × 32/64-bit × Substrate metadata version × target chain runtime. Runtime upgrades change types, so "works on testnet" is a moving target — pin the metadata version you generate types from.
  • Assume no forward compatibility guarantees across minor versions until proven; treat every bump as a reviewed change with the conformance suite as the gate.

Sequencing

  1. Spike (1 week): install, reproduce parity golden vectors, confirm hashing/SS58 coverage. This is the go/no-go gate.
  2. Decode path: balances, storage values, block events, extrinsics from a dev node. Ship behind a feature flag, read-only.
  3. Encode path: construct unsigned extrinsic call bytes; diff byte-for-byte against a known-good payload (e.g., generated by subxt/polkadot-js) for the same inputs.
  4. Signing + submission: only after 2 and 3 are provably byte-identical. Signing is where an off-by-one becomes a lost transaction.
  5. Metadata-driven type generation: only if you need multi-pallet coverage; otherwise hand-model the 2–3 pallets you actually call.

Operational Impact

Maintenance

  • Bus factor of one, no dependents, low opportunity score: plan for the package to go stale. Fork it into your VCS on day one (MIT permits this) and consume your fork via a VCS repository entry. You keep the upgrade path while removing the "maintainer disappears" risk.
  • Dependabot with review-only (never auto-merge). Budget roughly 1–2 engineer-days per month for upstream watching; expect a spike of 3–5 days around any target-chain runtime upgrade.

Support

  • There is no community or vendor to escalate to. Internal ownership is mandatory: a named owner, a runbook, and a documented "how to re-derive byte layouts" guide. Without that, this becomes tribal knowledge in one engineer's head.

Scaling

  • The codec itself is stateless and CPU-bound: scales horizontally with zero coordination and belongs in queue workers, not web requests.
  • Realistic hot path is batch decoding of block events or indexer backfills. Watch GMP allocation churn on u128-heavy loops and peak memory on large Vec decode. Set explicit memory and time limits on any job that decodes chain-supplied bytes.

Failure modes and mitigations

  • Silent misalignment (highest severity): a wrong prefix decodes into plausible-looking but wrong data with no error. Mitigate with round-trip assertions and byte-equality fixtures against an independent implementation in CI.
  • Integer overflow/truncation: wrong-width or 32-bit environments corrupt values quietly. Mitigate by asserting 64-bit + GMP at boot and failing fast.
  • Memory exhaustion from hostile input: cap decoded collection lengths at the application boundary; do not trust the codec to.
  • Metadata drift after a runtime upgrade: decode failures appear as exceptions in production. Mitigate with a canary job that decodes the latest block on every deploy.
  • Upstream abandonment: mitigated by the fork, not by hope.

Ramp-up

  • SCALE is conceptually simple but detail-dense (compact encoding, Option prefix byte, enum indices, little-endian ordering, composite type ordering). PHP developers will have no Polkadot context.
  • Estimate 1–2 weeks for a mid-level PHP engineer to be productive on decode with an internal annotated-examples doc, and 4–6 weeks end-to-end including signing and metadata handling. Upstream docs are likely thin — budget for writing your own, and treat that doc as a required deliverable of the spike, not an afterthought.
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.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core