PHP code example of domingollanes / strong-parameters-bundle

1. Go to this page and download the library: Download domingollanes/strong-parameters-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/ */

    

domingollanes / strong-parameters-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new DomingoLlanes\StrongParametersBundle\StrongParametersBundle(),
        );

        // ...
    }

    // ...
}


// src/AppBundle/Controller/DefaultController.php

// ...

    public function testAction(Request $request, ParametersService $parametersService)
    {
        // ...

        // For $_GET parameters
        $params = $parametersService->permitParameters('user', $request->query->all());

        // For $_POST parameters
        $params = $parametersService->permitParameters('user', $request->request->all());

        // For Content/json parameters
        $params = $parametersService->permitParameters('user', json_decode($request->getContent(), true));
        // ...
    }
    
// ...


array:2 [
  "test" => "testValue"
  "test2" => array:1 [
    "test1" => array:2 [
      "t2" => "t2Value",
      "t3" => "t3Value"
    ]
  ]
]