Skip to content

Instantly share code, notes, and snippets.

View sufimalek's full-sized avatar
🖥️
Learning Go

Sufiyan Malek sufimalek

🖥️
Learning Go
  • India
View GitHub Profile
@sufimalek
sufimalek / check.php
Created July 15, 2019 14:16
php check multidimensional array for duplicate values
<?php
$arrays = array(
array(
'name'=>'foo',
),
array(
'name'=>'bar',
),
array(
@sufimalek
sufimalek / Dockerfile
Last active December 31, 2018 13:56
Docker file for php7.2-apache
FROM ubuntu:18.04
LABEL maintainer="Sufiyan Malek sufiyanmalek78@gmail.com"
RUN apt-get update && apt-get install -yq --no-install-recommends \
apt-utils \
curl \
# Install git
git \
@sufimalek
sufimalek / LocaleListener.php
Last active April 17, 2019 18:18
LocaleListener Symfony3
<?php
namespace YourBundle\EventListener;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
@sufimalek
sufimalek / readme.txt
Created March 29, 2018 13:25
internationalization in symfony2/3
/**
* @Route("/change/locale/{current}/{locale}/", name="locale_change")
*/
public function setLocaleAction($current, $locale)
{
$this->get('request')->setLocale($locale);
$referer = str_replace($current,$locale,$this->getRequest()->headers->get('referer'));
return $this->redirect($referer);
}
@sufimalek
sufimalek / ClientCreateCommand.php
Created March 29, 2018 13:22
Symfony2 command for creating a Client for FOSOAuthServerBundle
<?php
namespace Acme\Bundle\OAuthBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class ClientCreateCommand extends ContainerAwareCommand
{
protected function configure ()
<?php
namespace Acme\Bundle\I18nBundle\EventListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
class LocaleListener
{
private $container;
private $locales;
public function __construct(ContainerInterface $container, array $locales)
@sufimalek
sufimalek / managed_schema_to_schema.txt
Created August 30, 2017 10:58
Remove managed-schema and get schema.xml in SOLR core [ Version 5.5.0 and above ]
Lets say solr is located at /usr/local/solr-5.5.0 .
1. bin/solr start
2. bin/solr create -c test
3. location of new core is here /usr/local/solr-5.5.0/server/solr/test
4. location of solrconfig is here /usr/local/solr-5.5.0/server/solr/test/solrconfig.xml
5. Open solrconfig.xml -
You will find this
<schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">true</bool>
<str name="managedSchemaResourceName">managed-schema</str>
@sufimalek
sufimalek / gist:ebf6bf20f3db8537d503463a9e4a7211
Created March 29, 2017 13:46 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@sufimalek
sufimalek / 1-Readme.md
Created October 14, 2015 08:02 — forked from FlYos/1-Readme.md
Redirection user by roles after login/logout in symfony2

Description of this Gist

This is the how to for redirection implementation by roles after login or logout in Symfony2

Step

  1. Copy AfterLoginRedirection.php and AfterLogoutRedirection.php to your bundle under the "Redirection" directory
  2. Edit your services.yml file in your bundle and copy/paste the content of services.yml
  3. Edit your security.yml file...
  4. ... add success_handler: redirect.after.login in form_login: section
  5. ... add success_handler: redirect.after.logout in logout: section