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

Php Percent Laravel Package

assoconnect/php-percent

Small PHP library to represent and work with percentages in a way that pairs well with MoneyPHP, based on Frederik Bosch’s proposal. Install via Composer and use the PHPDoc-documented API to apply percent calculations safely alongside Money values.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Pricing & Monetization: Simplify percentage-based calculations (e.g., discounts, fees, commissions) for subscription models, SaaS tiers, or dynamic pricing.
  • Financial Calculations: Accelerate development of tax, tip, or split-payment features by leveraging MoneyPHP’s precision and this package’s abstraction.
  • Build vs. Buy: Avoid reinventing percentage logic (e.g., rounding, currency conversion) when integrating with MoneyPHP—reduces technical debt.
  • Type Safety & Maintainability: Standardized PHPStan configuration improves code quality and reduces runtime errors by enforcing stricter type checking (e.g., float return types for percentage calculations).
  • Use Cases:
    • E-commerce: Dynamic discounts (e.g., "15% off if cart > $100").
    • Payroll: Variable tax/benefit percentages tied to salary ranges.
    • Marketplaces: Fee structures (e.g., "3% per transaction + $0.50").

When to Consider This Package

  • Adopt if:
    • Your app uses MoneyPHP for monetary operations and needs percentage calculations (e.g., splits, adjustments).
    • You prioritize precision (e.g., financial apps) over raw speed (this adds minimal overhead).
    • Your team lacks time to validate edge cases (e.g., rounding, negative percentages, multi-currency).
    • You want better type safety and maintainability via PHPStan integration (e.g., avoiding silent float-to-int conversions).
  • Look elsewhere if:
    • You’re not using MoneyPHP (this is a tight integration).
    • Your use case is trivial (e.g., static 10% discounts—use basic arithmetic).
    • You need real-time analytics (this is a computation layer, not a reporting tool).
    • You’re not using PHPStan and don’t want to enforce stricter type checks (though this is a non-breaking baseline change).

How to Pitch It (Stakeholders)

For Executives: "This package lets us handle percentage-based pricing/fees with financial-grade accuracy—like discounts or transaction fees—without building custom logic. It integrates seamlessly with our existing MoneyPHP stack, reducing risk and speeding up feature delivery (e.g., dynamic pricing tiers). The latest release adds PHPStan support to enforce type safety, catching potential bugs early. MIT-licensed and actively maintained, it’s a low-risk way to standardize calculations across the product while improving code quality."

For Engineering: "If we’re already using MoneyPHP, this package gives us a clean, tested way to handle percentages (e.g., 20% of $100.50 in USD/EUR) with proper rounding and currency conversion. The new PHPStan baseline ensures we catch type issues (e.g., float vs. int mismatches) before runtime. Adoption is minimal—just add the package and follow its conventions. Tradeoff: slight dependency, but saves us from debugging edge cases like 100% of $0.99 and improves maintainability."

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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony