- What is jgrossi/petty and what does it do?
- Petty is a small Laravel/PHP package by jgrossi that lets you run your own URL shortener on your own domain. It is intentionally minimal and focused, so it suits lightweight projects where a full-featured shortening platform would be overkill. You install it with Composer and wire it into your Laravel app. See the GitHub repository for the exact feature set and usage details.
- How do I install Petty in a Laravel application with Composer?
- Install the package with Composer using composer require jgrossi/petty, then follow the repository README for any service provider or configuration steps. Laravel package discovery typically handles registration, but confirm this in the docs for your version. After installation, publish any provided config and define your short domain. Always check the README because setup details can change between releases.
- Which Laravel versions does Petty support?
- The package is distributed via Composer, and supported Laravel versions are defined in its composer.json constraints. Check that file and the README before installing on older or newer Laravel releases. If your app uses a version outside the constraint, Composer will refuse the install or require an update. Testing on a staging copy first is the safest approach.
- Can I use my own domain for shortened URLs with Petty?
- Yes. Petty is described as a way to have your own URL shortener using your own domain. You point a domain or subdomain at your Laravel application and configure the package to generate short links with that host. The exact configuration keys are documented in the repository. You will also need DNS and web server routing for that domain.
- How do I configure Petty after installing it?
- Configuration is handled through the package config and your Laravel application environment. The README is the source of truth for publishable config files, route setup, and domain settings. Keep sensitive values such as database credentials in your .env file rather than committed config. Clear cached config after changes with php artisan config:clear.
- Is Petty suitable for production use?
- Petty is a minimal utility, so production suitability depends on your traffic, storage, and redirect performance needs. Review the package code and README, add database indexes for short codes, and cache redirects if you expect high volume. Run it behind HTTPS on your own domain and monitor error rates. For large-scale shorteners, evaluate whether a more feature-complete package or service fits better.
- Does Petty require a database, and how are shortened links stored?
- The repository README and package source are the best place to confirm storage requirements, since Petty is intentionally minimal. A URL shortener typically needs somewhere to persist the mapping between short codes and destination URLs, often a database table. Check for migrations or model classes in the package to see what it expects. If it does not ship migrations, you may need to create and configure storage yourself.
- How do I test a URL shortener built with Petty?
- Test the shortener with Laravel's HTTP tests by creating a short link and asserting the redirect response and Location header. Use a fresh test database or an in-memory SQLite connection so link records do not leak between tests. Cover invalid URLs, unknown short codes, and duplicate-code handling. Run the package test suite if one is included in the repository.
- What are alternatives to Petty for URL shortening in Laravel?
- Alternatives include building a small shortener yourself with Laravel routes and a links table, or using fuller packages and hosted services. Petty's advantage is that it is tiny and keeps links on your own domain. Compare maintenance activity, Laravel version support, and features such as analytics, custom slugs, and API access before choosing. Check Packagist and GitHub for current alternatives.
- Is Petty actively maintained, and how do I report issues?
- Maintenance status is best checked on the GitHub repository, including recent commits, open issues, and tagged releases. If you find a bug, open an issue with your Laravel and PHP versions and steps to reproduce. For fixes, submit a pull request that follows the project's coding style. If the package is unmaintained, fork it or pin a working version in composer.json.