jgrossi/petty
Composer 安装命令:
composer create-project jgrossi/petty
包简介
A very simple URL shortener using custom domains
关键字:
README 文档
README
Have your own URL shortener, using your own domain, with easy.
Petty is a small PHP app (made with Laravel) that allows you to host your own URL shortener. It's clean and easy to use and install, allowing you to have your own shortener in a few minutes.
For now it does not support statistics, that is made initially by Bitly. We're working on new features and in the future Petty will do all the job. Please, contribute with the project and suggest new features.
How it works
Petty shorts the original URL generating new URLs like http://doma.in/m9. This URL redirects to a Bitly shorten URL (where, if you want, you can get more statistics) and after to the original URL.
The app uses your own domain, and the generated URLs are customized for you. All generated URL are stored in a Sqlite database and generated using your Laravel APP_KEY, so using http://doma.in/m9 as example, the m9 is generated only for you, and represents a row stored in your local database. The generated hash (m9) has at least 2 chars length.
Installing
The easier and recommended way to install Petty is using the create-project command in Composer:
composer create-project --prefer-dist jgrossi/petty my-shortener
You can also clone this repo and run composer install to get all PHP dependencies, but this way you have to generate Laravel application key php artisan key:generate by hand. The recommended installation is using create-project that does everything Petty needs to run.
After Petty installed you have only to run your webserver in the /public folder and access the URL. Petty will have everything working, including database.
Attention! Your web root (virtual host) will be my-shortener/public!
Usage
As Petty for now does not provide more statistics (only clicks) every short URL has your Bitly correspondent. So before use your own URL shortener you should create a free Bitly account and set your username and password to the .env file. More information in the Configuration section below.
Configuration
All configuration is made using .env. You'll have a .env.sample that was copied to the .env file when you've installed Petty. You have to customize this file with your personal data, URL, name, avatar image, and Bitly username and password.
APP_ENV=local # Your app env
APP_DEBUG=true # Enabe or disable debug?
APP_KEY=8gboHDJkh2q80dRPFcy6y0X5PsaUVcKa # This key is generated when you install Petty
DB_CONNECTION=sqlite
DB_FILE="database.sqlite" # You can change this if you want
CACHE_DRIVER=file # Laravel default
SESSION_DRIVER=file # Laravel default
QUEUE_DRIVER=sync # Laravel default
# The domain you want to use, like http://doma.in
PETTY_DOMAIN="http://petty.dev"
# Minimum number of chars, like http://doma.in/m8 - the number 1 won't work
PETTY_SIZE=2
# Your avatar image. By default we have set 2 avatars: `avatar-male.png` and `avatar-female.png` - Tranks to http://www.freepik.com. You can store your own image in `public` directory and link that, like `img/your-custom-avatar.png`;
PETTY_AVATAR="img/avatar-male.png"
# Your own name, like "Junior Grossi"
PETTY_NAME="Your Name"
# Your Bitly username. If you don't have one just signup and get yours for free
PETTY_USERNAME="jgrossi"
# Your Bitly password
PETTY_PASSWORD=secret
Running your own assets
By default all css and js files are stored in public folder minified and merged. If you want to customize your assets files, like changing css or even js I suggest to install bower packages and elixir (gulp). This will take a little:
bower install
npm install
Bower will install Bootstrap, Clipboard.js, FontAwesome, jQuery and jQuery-UJS (by Ruby on Rails). NPM will install gulp and all Elixir dependencies.
After that you will have 3 more directories in your folder root: vendor (PHP packages by Composer), bower_components (packages by Bower) and node_modules (packages by Node JS). The original css and js files are stored in resources/assets folder.
Running gulp watch --production will allow you to change the resources/assets/css/*.less and resources/assets/js/*.js files. So, after that gulp will merge everything and minify the result, storing them in public/css/styles.css and public/js/scripts.js, respectively.
You can also change and customize the views (HTML), change colors, etc. Bee free to make Petty like you want.
Contributing
Thank you for considering contributing to the Petty URL Shortener! Just made your changes, suggest and create a pull request to the dev branch. Any question just ask in issues section. Any help or suggestion is welcome!
Petty has much to grow. This is the first release and that's the minimum to a URL shortener works. So, please send features suggestions, statistics suggestions and what you think will be good to the package.
Licence
MIT License © Junior Grossi
jgrossi/petty 适用场景与选型建议
jgrossi/petty 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 63 次下载、GitHub Stars 达 7, 最近一次更新时间为 2016 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「url」 「shortener」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jgrossi/petty 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jgrossi/petty 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jgrossi/petty 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel package to shorten urls
Easy URL rewrites in your Laravel application
Laravel 7 local url shortener
A Laravel helper to detect if the current route/path is active.
Provides a service and twig extension for getting short urls like http://your.host/~short
Alfabank REST API integration
统计信息
- 总下载量: 63
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-19
