ShortUrlBundle
This bundle provides a service and twig extension for getting short urls like http://your.host/~short
Installation
Add this bundle to your project
Using the vendors script
Add the following lines in your deps file:
[BumzShortUrlBundle]
git=git://github.com/biozshock/ShortUrlBundle.git
target=bundles/Bumz/ShortUrlBundle
Run the vendors script:
$ php bin/vendors install
Using Git submodule
$ git submodule add git://github.com/biozshock/ShortUrlBundle.git vendor/bundles/Bumz/ShortUrlBundle
Add the Bumz namespace to your autoloader
<?php
// app/autoload.php
$loader->registerNamespaces(array(
'Bumz' => __DIR__.'/../vendor/bundles',
// your other namespaces
));
Add this bundle to your application's kernel
<?php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Bumz\ShortUrlBundle\BumzShortUrlBundle(),
// ...
);
}
Add bundle's routing
# /app/config/routing.yml
BumzShortUrlBundle:
resource: "@BumzShortUrlBundle/Resources/config/routing.yml"
prefix: /
Examples
Short url in a controller
<?php
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class UsersController extends Controller
{
public function getUserProfileShortAction()
{
...
$longUrl = $this->get('bumz_short_url.shortener')->shorten('http://example.com');
// $longUrl = '/~ShE'
...
}
}
Get long url in controller
<?php
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class UsersController extends Controller
{
public function getUserProfileShortAction()
{
...
$shortUrl = 'aUty';
$longUrl = $this->get('bumz_short_url.shortener')->getLong($shortUrl);
// $longUrl = 'http://example.com'
...
}
}
Get short url in a twig template
{{ 'http://example.com' | shortenUrl }}
{# this will output something like /~ShE #}
Copyright (c) 2012 Artem Lopata - http://biozshock.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
bumz_short_url:
shortener: base
shortLength: 3
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Added travis build config and it's status to readme
By Artem Lopata, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Merge remote-tracking branch 'origin/patch-1'
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago
-
Fixed compatibility with latest symfony2 framework
By biozshock, 3 months ago

