2017 © Pedro Peláez
 

library adflybundle

Adfly Url Shortener Symfony Bundle

image

nmdev/adflybundle

Adfly Url Shortener Symfony Bundle

  • Tuesday, January 27, 2015
  • by rmed19
  • Repository
  • 2 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Using NmAdflyBundle

Welcome to NmAdflyBundle - a Symfony bundle to make short url using Adfly api, (*1)

Installation

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()
    );
}

The Versions

27/01 2015

dev-master

9999999-dev https://github.com/rmed19/adflybundle

Adfly Url Shortener Symfony Bundle

  Sources   Download

MIT

The Requires

 

symfony shortener adfly