dev-master
9999999-dev https://github.com/rmed19/adflybundleAdfly Url Shortener Symfony Bundle
MIT
The Requires
- php >=5.3.3
- symfony/framework-bundle ~2.3
symfony shortener adfly
Wallogit.com
2017 © Pedro Peláez
Adfly Url Shortener Symfony Bundle
Welcome to NmAdflyBundle - a Symfony bundle to make short url using Adfly api, (*1)
Step 1: Download the Bundle ~~~~~~~~~~~~~~~~~~~~~~~~~~~, (*2)
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*3)
.. code-block:: bash, (*4)
$ composer require nmdev/adflybundle
This command requires you to have Composer installed globally, as explained
in the installation chapter_ of the Composer documentation., (*5)
Step 2: Enable the Bundle ~~~~~~~~~~~~~~~~~~~~~~~~~, (*6)
Then, enable the bundle by adding the following line in the app/AppKernel.php
file of your project:, (*7)
.. code-block:: php, (*8)
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Nm\AdflyBundle\NmAdflyBundle(),
);
// ...
}
// ...
}
Step 3: Configure the bundle, (*9)
To use Adfly API at first you need to get your API key and your user id. If you are a Adfly member you can get these by following way. Go to tools-api_. .. _tools-api: http://adf.ly/publisher/tools#tools-api .. code-block:: yaml # app/config/config.yml nm_adfly: key : ADDFLY_API_KEY #Your api key uid : USER_ID #your user id advert_type : int #(optional) int || banner domain : adf.ly #(optional) adf.ly || q.gs Usage
.. code-block:: php // Acme\MainBundle\Controller\ArticleController.php, (*10)
public function updateAction($id)
{
$em = $this->getEntityManager();
$article = $em->getRepository("AcmeMainBundle:Article")->find($id);
$editForm = $this->createEditForm($document);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$showLink = $this->generateUrl("article_show", array('slug' => $post->getId()), true);
$adflyLink = $this->get('nm_adfly.manager')->adflyIt($showLink);
$article->setAdflyLink($adflyLink);
$this->persistAndFlush($article);
return $this->redirect($showLink);
}
return array(
'article' => $article,
'edit_form' => $editForm->createView()
);
}
Adfly Url Shortener Symfony Bundle
MIT
symfony shortener adfly