1. Go to this page and download the library: Download ekino/wordpress-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/ */
ekino / wordpress-bundle example snippets
public function registerBundles()
{
$bundles = array(
...
new Ekino\WordpressBundle\EkinoWordpressBundle(),
);
...
return $bundles;
}
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Retrieves or sets the Symfony Dependency Injection container
*
* @param ContainerInterface|string $id
*
* @return mixed
*/
function symfony($id)
{
static $container;
if ($id instanceof ContainerInterface) {
$container = $id;
return;
}
return $container->get($id);
}
$loader = ($sfRequest);
$sfResponse->send();
$sfKernel->terminate($sfRequest, $sfResponse);
use Symfony\Component\HttpFoundation\Request;
// change for app_dev.php
function run(){
$loader = oadClassCache();
Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
}
run();
# Here an example that sets user #2 as author for post #1
$postManager = $this->get('ekino.wordpress.manager.post');
$userManager = $this->get('ekino.wordpress.manager.user');
$user = $userManager->find(2);
$post = $postManager->find(1);
$post->setAuthor($user);
$postManager->save($post);
$service = symfony('my.custom.symfony.service');
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
class LanguageController extends Controller
{
/**
* @param Request $request
* @param string $locale
*
* @return RedirectResponse
*/
public function toggleLocaleAction(Request $request, $locale)
{
$response = new RedirectResponse($this->generateUrl('homepage'));
$response->headers->setCookie(new Cookie($this->getWpCookieName(), $locale, time() + 31536000, '/', $request->getHost()));
return $response;
}
/**
* @return string
*/
protected function getWpCookieName()
{
return $this->container->getParameter('ekino.wordpress.i18n_cookie_name');
}
}