PHP Classes
elePHPant
Icontem

Jaxon for Symfony: Jaxon integration for the Symfony framework

Recommend this page to a friend!
  Info   View files Documentation   Demos   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-05-29 (3 months ago) RSS 2.0 feedNot enough user ratingsTotal: 33 All time: 8,999 This week: 684Up
Version License PHP version Categories
jaxon-symfony 2.0.0BSD License5PHP 5, Libraries, Language, AJAX, Traits
Description Author

This package integrates the Jaxon library with the Symfony framework, allowing to make AJAX calls to PHP classes.

This package automatically export all PHP classes installed in a given directory to Javascript, so their methods can be called directly from the browser.

The Jaxon library provides a Response object that allows in the PHP application to modify the content and layout of a page, and execute Javascript code on the client side.

  Performance   Level  
Name: Thierry Feuzeu <contact>
Classes: 10 packages by
Country: Cameroon Cameroon
Age: 41
All time rank: 28503 in Cameroon Cameroon
Week rank: 20 Up1 in Cameroon Cameroon Up
Innovation award
Innovation award
Nominee: 1x

Details

Jaxon Library for Symfony

This package integrates the Jaxon library into the Symfony framework.

Features

  • Automatically register Jaxon classes from a preset directory.
  • Read Jaxon options from a config file.

Installation

Add the following lines in the composer.json file, and run the composer update command.

"require": {
    "jaxon-php/jaxon-symfony": "~2.0"
}

Declare the Jaxon bundle in the app/AppKernel.php file.

$bundles = array(
    ...
    new Jaxon\AjaxBundle\JaxonAjaxBundle(),
);

Setup the default routing for Jaxon request by adding the following line in the app/config/routing.yml config file.

jaxon_ajax:
    resource: "@JaxonAjaxBundle/Resources/config/routing.yml"
    prefix:   /

Import the service definition and configuration file of the Jaxon bundle in the app/config/config.yml config file.

imports:
    ...
    - { resource: jaxon.yml }
    - { resource: "@JaxonAjaxBundle/Resources/config/services.yml" }

Create and edit the app/config/jaxon.yml file to suit the needs of your application. A sample config file is available online at the examples repo.

Configuration

The settings in the app/config/jaxon.yml config file are separated into two sections. The options in the lib section are those of the Jaxon core library, while the options in the app sections are those of the Symfony application.

The following options can be defined in the app section of the config file.

| Name | Description | |------|---------------| | classes | An array of directory containing Jaxon application classes | | views | An array of directory containing Jaxon application views | | | | |

By default, the views array is empty. Views are rendered from the framework default location. There's a single entry in the classes array with the following values.

| Name | Default value | Description | |------|---------------|-------------| | directory | jaxon/Classes | The directory of the Jaxon classes | | namespace | \Jaxon\App | The namespace of the Jaxon classes | | separator | . | The separator in Jaxon class names | | protected | empty array | Prevent Jaxon from exporting some methods | | | | |

Usage

This is an example of a Symfony controller using the Jaxon library.

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class DemoController extends Controller
{
    public function indexAction(Request $request)
    {
        // Register the Jaxon classes
        $jaxon = $this->get('jaxon.ajax');
        $jaxon->register();
        // Print the page
        return $this->render('demo/index.html.twig',
            'jaxon_css' => $jaxon->css(),
            'jaxon_js' => $jaxon->js(),
            'jaxon_script' => $jaxon->script()
        ]);
    }
}

Before it prints the page, the controller makes a call to $jaxon->register() to export the Jaxon classes. Then it calls the $jaxon->css(), $jaxon->js() and $jaxon->script() functions to get the CSS and javascript codes generated by Jaxon, which it inserts in the page.

The Jaxon classes

The Jaxon classes must inherit from \Jaxon\Sentry\Classes\Base. By default, they are located in the jaxon/Classes dir of the Symfony application, and the associated namespace is \Jaxon\App.

This is a simple example of a Jaxon class, defined in the jaxon/Classes/HelloWorld.php file.

namespace Jaxon\App;

class HelloWorld extends \Jaxon\Sentry\Classes\Base
{
    public function sayHello()
    {
        $this->response->assign('div2', 'innerHTML', 'Hello World!');
        return $this->response;
    }
}

Check the jaxon-examples package for more examples.

Contribute

  • Issue Tracker: github.com/jaxon-php/jaxon-symfony/issues
  • Source Code: github.com/jaxon-php/jaxon-symfony

License

The package is licensed under the BSD license.

  Jaxon for Symfony DemoExternal page  
  Files folder image Files  
File Role Description
Files folder imageapp (1 directory)
Files folder imagesrc (4 files, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  app  
File Role Description
Files folder imageconfig (1 file)

  Files folder image Files  /  app  /  config  
File Role Description
  Accessible without login Plain text file jaxon.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageController (1 file)
Files folder imageResources (1 directory)
  Accessible without login Plain text file Jaxon.php Class Class source
  Accessible without login Plain text file JaxonAjaxBundle.php Class Class source
  Accessible without login Plain text file Session.php Class Class source
  Accessible without login Plain text file View.php Class Class source

  Files folder image Files  /  src  /  Controller  
File Role Description
  Accessible without login Plain text file JaxonController.php Class Class source

  Files folder image Files  /  src  /  Resources  
File Role Description
Files folder imageconfig (2 files)

  Files folder image Files  /  src  /  Resources  /  config  
File Role Description
  Accessible without login Plain text file routing.yml Data Auxiliary data
  Accessible without login Plain text file services.yml Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:33
This week:0
All time:8,999
This week:684Up