PHP code example of kl3ryk / symfony-facebook-bundle

1. Go to this page and download the library: Download kl3ryk/symfony-facebook-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kl3ryk / symfony-facebook-bundle example snippets


// Controllers/YourSymfonyController.php

class YourSymfonyController extends Controller
{
    function indexAction()
    {
        $readyToUseFacebookSdk = $this->get('facebook');
        // ... done
    }
}

// Appkernel.php

class AppKernel
{
    public function registerBundles()
    {
        return [
            // ...
            new \Laelaps\Bundle\Facebook\FacebookBundle,
            // ...
        ];
    }
}

// DependencyInjection/YourExtension.php

use Laelaps\Bundle\Facebook\FacebookExtensionInterface;
use Laelaps\Bundle\Facebook\FacebookExtensionTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class YourExtension extends Extension implements FacebookExtensionInterface
{
    use FacebookExtensionTrait;

    public function load(array $configs, ContainerBuilder $container)
    {
        print_r($configs);
        /*
            (
                [application_id] => example_application_id
                [secret] => example_secret
                [file_upload] =>
                [permissions] => Array
                    (
                    )

                [trust_proxy_headers] =>
            )
        */
    }
}

// DependencyInjection/YourExtension.php

use Laelaps\Bundle\Facebook\FacebookExtensionInterface;
use Laelaps\Bundle\Facebook\FacebookExtensionTrait;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

class YourExtension extends Extension implements FacebookExtensionInterface
{
    use FacebookExtensionTrait;

    public function getFacebookConfigurationPrefix(array $config, ContainerBuilder $container)
    {
        return 'facebook_';
    }

    public function load(array $configs, ContainerBuilder $container)
    {
        print_r($configs[0]);
        /*
            (
                [facebook_application_id] => example_application_id
                [facebook_secret] => example_secret
                [facebook_file_upload] =>
                [facebook_permissions] => Array
                    (
                    )

                [facebook_trust_proxy_headers] =>

            )
        */
    }
}