How to seprate Appfrontend and AppBackend

It is very complected point for any framework   How to separate frontend and backend workflow structure..

For symfony i am giving you some tips to work with better way….

You have to create  bundle for front end

Appfrontend

and also for backend

AppBackend

And under these folder you have to create your other action

like

public function welcomeAction()

public function aboutUsAction()

public function industryAction()

How to manage fronend home page routing

pattern:  /                         (you have to use blank pattern)
defaults: { _controller: MyAppMainBundle:frontEnd:welcome }

for other

aboutus:
pattern:  /about_us
defaults: { _controller: MyAppMainBundle:frontEnd:aboutus }

Thanks

Vinod Kumar Maurya (Lead eng OSScube)

 

Advertisements

10 thoughts on “How to seprate Appfrontend and AppBackend

    • Hi dipak,

      Simply create AdminBundle
      DefaultController .php

      getRequest()->getSession();
      $sessionid = $session->get(‘adminlogin’);

      if($sessionid)
      {
      return $this->render(‘AdminAdminBundle:Default:login.html.twig’, array(‘name’ => ‘Administrator’,’sessionid’=>$sessionid));
      }

      if($request->getMethod()==’POST’)
      {

      $username=$request->get(‘username’);
      $password=$request->get(‘password’);
      if($username==”” && $password==””)
      {
      return $this->render(‘AdminAdminBundle:Default:index.html.twig’,array(‘Error’=>’Please Enter valid username and password’));
      }

      else
      {
      $em=$this->getDoctrine()->getEntityManager();
      $repository=$em->getRepository(‘AdminAdminBundle:Admins’);
      $adminUser=$repository->findOneBy(array(‘userName’=>$username,’password’=>sha1($password)));

      $sessionid=$adminUser->getId();
      $session->set(‘adminlogin’,$sessionid);
      if($sessionid==””)
      {
      return $this->render(‘AdminAdminBundle:Default:index.html.twig’, array(‘Error’ => ‘login failed’,’sessionid’=>”));
      }

      else
      {
      return $this->render(‘AdminAdminBundle:Default:login.html.twig’, array(‘name’ => ‘Welcome to ‘.ucwords($adminUser->getFirstName()).’You have Login Successfully’,’sessionid’=>$sessionid));
      }
      }
      }
      else

      {

      return $this->render(‘AdminAdminBundle:Default:index.html.twig’);

      }
      }

      public function adminlogoutAction(Request $request)
      {

      $session =$this->getRequest()->getSession();
      $sessionid = $session->get(‘adminlogin’);

      $session->clear();
      return $this->render(‘AdminAdminBundle:Default:index.html.twig’);
      }

      }
      // depandency injection

      processConfiguration($configuration, $configs);

      $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.’/../Resources/config’));
      $loader->load(‘services.yml’);
      }
      }

      /Admin Entity

      id;
      }

      /**
      * Set userName
      *
      * @param string $userName
      * @return Admins
      */
      public function setUserName($userName)
      {
      $this->userName = $userName;

      return $this;
      }

      /**
      * Get userName
      *
      * @return string
      */
      public function getUserName()
      {
      return $this->userName;
      }

      /**
      * Set firstName
      *
      * @param string $firstName
      * @return Admins
      */
      public function setFirstName($firstName)
      {
      $this->firstName = $firstName;

      return $this;
      }

      /**
      * Get firstName
      *
      * @return string
      */
      public function getFirstName()
      {
      return $this->firstName;
      }

      /**
      * Set password
      *
      * @param string $password
      * @return Admins
      */
      public function setPassword($password)
      {
      $this->password = $password;

      return $this;
      }

      /**
      * Get password
      *
      * @return string
      */
      public function getPassword()
      {
      return $this->password;
      }
      }

      You have to also create table name Admins

      id,user_name,first_name,password

      /// index.html.twig

      {% extends ‘::base.html.twig’ %}
      {% block body -%}

      {{ Error | default(“”) }}
      {{ adminlogin | default(“”) }}
      {% if adminlogin|default is empty %}

      Signin

      {%endif%}

      {% endblock %}

      // Appkernal.php

      new Admin\AdminBundle\AdminAdminBundle(),

  1. I want to know that what is best authentication about symfony either custom or use fosbundle or sonta like that because I would like to develop my own method of authentication and work on that. can you guide me?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s