Symfony & Eclipse IDE

Introduction

Eclipse is a free IDE used for software development. It’s not necessarily the most popular one, but it’s free and easy to use, plus it supports many languages and is open source and easy to customize. There is a lot of support available, so if you have problems it’s very easy to find out and fix the problems.

Symfony is a popular PHP web framework. I have personally evaluated it against a few other frameworks and find it to be one of the best and easiest to use out there.

This blog is about setting up your Eclipse IDE environment to work with Symfony.

Remote Systems Explorer

In my typical environment, Symfony is installed on a server (RHEL or CentOS) and my Eclipse IDE is on a remote client. I normally use Windows client, but the usage of Eclipse on Linux should be similar.

In Eclipse, select “Window > Show View > Other…”; then expand the “Remote Systems” folder and click on “Remote Systems”. Normally, I’ll move this window to the left pane of Eclipse. Then to add a SSH connection to your server that hosts Symfony, perform the following steps:

  1. Right-click in the Remote Systems pane and select “New Connection…”.
  2. Select “SSH Only” and click “Next >”.
  3. Enter in the “Host name”, which can be a DNS name or an IP address.
  4. Enter a “Connection name”. This can be whatever you like, and make it a suitable name to identify the host easily to you.
  5. Then at this point you can click the “Finish” button to complete adding the connection.

I suggest then creating a sftp filter for just the web folder, instead of you having to expand each of the folders every time you need to re-establish a connection to the remote server. In these steps I’ll presume you have Apache (httpd) installed, which has a specific path under the var folder.

  1. Right-click on “Sftp Files” and select “New > Filter…”.
  2. In the File Filter, enter the folder path as “/var/www/html” (path for Apache), then click “Next >”.
  3. Enter the “Filter name” as “WEB Root” (or whatever you prefer to call it), then click “Finish”.
  4. Then click on the “WEB Root” filter, and notice it prompts you to authenticate.
  5. Enter your username (User ID) and password on the remote host, and make sure the “Save password” button is checked.
  6. The filter expands to show you all directories under the WEB Root folder.

One point about the above connection and sftp filter: If you are not part of the root user group, or you are not the root user on the remote server, you will not be able to save files within the WEB Root folder using Eclipse. The easy workaround for this is to create a Development Environment described below.

Development Environment

As mentioned above, if you not the root user on the remote server, and for example you normally have to use “sudo” to save (or copy) files in the WEB Root folder, you will not be able to save files use Remote System Explorer in Eclipse. A good developer will always test their code in a Development Environment first to make sure everything works properly before deploying to the Production Environment, and this is what I will describe here.

Typically at Taft College, we use RHEL for our Production servers, and I will use CentOS as a Development Environment, since it is based on RHEL (although not quite similar). I setup CentOS in VirtualBox on my desktop, and I install everything as the root user. Then I setup Eclipse to connect as the root user, and I fully test my code on this test virtual machine. Once I’m ready to deploy my code, I use WinSCP to copy and transfer from my Development Environment to a sub folder in my HOME directory on the Production RHEL server. Then I use PuTTY to login to the Production server and use sudo to copy over the new or changed files to the Symfony sub directories. This whole process can be done quite quickly, and once you’ve done it a few times, it seems so easy to do.

 

Installing OCI8 on RHEL

Introduction

If you plan to use PHP to connect to an Oracle database, then you’ll want to install OCI8, which is a pecl extension for Oracle. You can also use PDO_OCI as mentioned in The Underground PHP and Oracle Manual, however Oracle does not contribute to PDO_OCI; if you look this up (for example on stackoverflow), you’ll find a number of users have had various problems getting PDO_OCI to work. So installing OCI8 is highly recommended!

Stop Apache

Run the following command to stop Apache:

sudo service httpd stop

Install Instant Client

Go to Oracle’s instant client download page, and select the link for you Linux architecture. You’ll have to click on the “Accept License Agreement” radio button, and you’ll have to download it somewhere and then transfer it to your Red hat Enterprise Linux Server (RHEL). RHEL distro doesn’t have a GUI, but just CLI, so the easiest way might be to transfer via scp. Download the latest version and both the “basic” and “devel” RPMs.

After copying the instant client RPMs to your home directory, run the following commands to install the RPMs:

sudo rpm -Uvh oracle-instantclient12.1-basic*
sudo rpm -Uvh oracle-instantclient12.1-devel*

You then need to set the ORACLE_HOME environment variable:

cd ~
vi .bashrc
ORACLE_HOME=/usr/lib/oracle/12.1/client64
export ORACLE_HOME
:wq!

Install Pear & Devel

In order to install OCI8, you first need to get pecl. Also pecl will need the development packages. Run the following commands:

sudo yum install php70u-pear php70u-devel

Install OCI8

At this point you should be ready to install OCI8:

pecl install oci8

Observe the output carefully, and make sure no errors are shown. If any errors are shown, you might have to review the above to make sure you haven’t missed anything, also you might want to read through The Underground PHP Oracle Manual.

Then when oci8 is installed, you now need to edit the PHP config file to add the compiled oci8.so file:

sudo vi /etc/php.ini
extension=oci8.so

Add “extension=oci8.so” at the very bottom of the file.

Verifying OCI8 is Installed

First restart Apache:

sudo service httpd restart

Then create a phpinfo() file in your Apache Document root folder, so you can access it via web browser. Then open in any browser, and then search for “oci8”. Make sure that it is enabled.

Apache & Symfony on RHEL

Introduction

For a Symfony (an mvc framework) based project that I’m currently working, I’ve had to install Apache (2.2) and Symfony 3 (and PHP 7) on Red Hat Enterprise Linux (RHEL). This blog outlines the steps I had to go through. This may be helpful for someone in the future.

Install/Configure Apache

Installing Apache on RHEL is as simple as running the following command:

yum install httpd

You need to prepend the above command with “sudo” if you don’t have admin privileges (which is typical).

Once installed, you’ll need to edit the config file:

vi /etc/httpd/conf/httpd.conf

If you notice when using vi that comments are shown with a incredibly hard to read dark blue color, then you’ll want to edit your “~/.vimrc” file to at least add “:color desert”. You can read more about it in my vim runtime control blog article.

Edit the httpd.conf file to at least make these changes:

ServerAdmin youremail@somedomain.com
...
# Use hostname if dns can be used, otherwise use IP address.
ServerName machine.host.name:80
#ServerName 192.168.0.10:80

That’s enough config until we install Symfony. Use “:wq!” to save the changes.

Install PHP 7.0

By default, RHEL would install PHP 5.x (probably PHP 5.3 at this time), and this may not actually work for most modern PHP frameworks. PHP 7.0 has about a 2 times performance increase over PHP 5.x and it’s becoming readily adopted. Thus it’s highly recommended to install PHP 7.0 these days.

To install PHP 7.0 on RHEL, you’ll need to enable the EPEL and IUS repositories. Use the following commands (run in your home directory) to first install EPEL:

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
sudo rpm -Uvh epel-release-*.rpm

Then install the IUS repo:

wget https://centos6.iuscommunity.org/ius-release.rpm
sudo rpm -Uvh ius-release*.rpm

When you’re using yum to search for PHP 7.0 items to install, you need to search for “php70u”. This identifies PHP 7 verses PHP 5, which is simply “php”. Now to install PHP 7 and some of the requirements needed for Symfony (and other PHP frameworks), run the following command:

sudo yum install php70u-cli php70u-json php70u-ldap php70u-mbstring php70u-pdo php70u-mysqlnd php70u-xml php70u-process

After running the above command, run “php -v” to verify it shows PHP version 7.

Install MariaDB

You should probably now be using MariaDB instead of MySQL. If you’re not sure why MariaDB is preferable, read the MariaDB article on Wikipedia. On RHEL, you’ll need to add a repository file. First go to: https://downloads.mariadb.org/mariadb/repositories/ and follow the instructions by selecting a Linux Distro and selecting the latest stable version of MariaDB.

Copy the text generated and paste it into the repo file that you will create with vi:

sudo vi /etc/yum.repos.d/MariaDB.repo

Save the file in vi (“:wq!”), then run the following command:

yum install MariaDB-server MariaDB-client

After install, start the service:

sudo service mysql start

Verify it starts correctly. If it doesn’t, try to figure out why before proceeding. Then change the root password to something more secure (especially if this is going to be a production machine). Use the following command, where newpassword is what you want to change the new password to:

sudo mysqladmin -u root password newpassword

Install Composer

Composer is a dependency management software for PHP, and is needed for Symfony and many other PHP frameworks. Run the following commands:

cd ~
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '92102166af5abdb03f49ce52a40591073a7b859a86e8ff13338cf7db58a19f7844fbc0bb79b2773bf30791e935dbd938') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"composer

This creates a “composer.phar” in your home directory. You need to copy it to the “/usr/local/bin” folder to make it globally available:

sudo mv composer.phar /usr/local/bin/composer

Run the command “composer” to verify it works.

Install Symfony Binary

Now install the latest Symfony binary. Don’t use the Symfony available with yum, since that is typically really old. Change to your home directory and run the following:

cd ~
sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony

Now, change to your Apache root web folder:

cd /var/www/html

Then let’s create a new Symfony project. This is a sample project that you can try out, and get to know how Symfony works:

symfony new testproject

Note: If for some reason “symfony” doesn’t run, you may need to run it from the absolute path or run with “sudo” or even using both. i.e. “sudo /usr/local/bin/symfony new testproject”.

The above creates the folder “testproject” under “/var/www/html”. Normally, you run the above commands as a system user not as the “apache” user, so you need to change the user:group of the folder and files. Do this recursively:

sudo chown -R apache:apache testproject

Also set some special permission on the var folder:

sudo setfacl -R -m u:"apache":rwX -m u:apache:rwX var
sudo setfacl -dR -m u:"apache":rwX -m u:apache:rwX var

Let’s go back to update the Apache config.

Apache Config

We need to update the DocumentRoot and Directory directives to the Symfony web folder we created above. The web folder will be under testproject, i.e. “testproject/web”. So make the following changes to the Apache config:

sudo vi /etc/httpd/conf/httpd.conf

DocumentRoot "/var/www/html/testproject/web"
...
<Directory "/var/www/html/testproject/web">
...
    Options Indexes FollowSymLinks MultiViews
...
    AllowOverride All
...
</Directory>

The above changes are needed also for mod_rewrite. Start the Apache server:

sudo service httpd start

Make sure it starts with “[OK]” normally, if not check the logs in “/var/log/httpd/”.

Verify Symfony Requirements

There were a large number of configuration items just performed, so it’s probably a good idea to check the Symfony requirements to verify everything you’ve installed is correct and no further changes are needed. There is a “symfony_requirements” script in the bin folder to achieve this specific purpose. From the “/var/www/html/testproject” folder run:

php bin/symfony_requirements

You should get a green [OK] if everything is fine, otherwise it prints out anything that you need to address.

RHEL SELINUX & IPTABLES

Most likely if you installed Apache fresh, then SELINX won’t be configured for the web folders, and quite possibly iptables are configured. Run the command “sudo iptables -S” to check the iptables configuration. If there is anything other than ACCEPT, and nothing specific to port 80, then most likely this will block your web port. Run “sudo iptables -F” to flush the tables.

The easiest way to quickly disable SELINUX is using “setenforce permissive”.

I’m not giving guidelines here on how to setup iptables or SELINUX, as for a production environment, a lot of thought should be put into correct configuration, and I only intend to show how to use Symfony here.

Checking Everything

Presuming your Apache server is running (run a “sudo service restart” if it is not), you should be able to use wget to check if everything is working “locally”:

cd ~
wget 192.168.0.10

This should copy an “index.html” to your home folder. Use “vi index.html” to check the contents. If you get errors, you need to investigate the problems.

After checking locally, use another machine and enter the hostname or IP address in the URL field of a browser. You should get a Symfony Welcome! message.

 

CakePHP Bookmarks Tutorial

Introduction

I have been going through the CakePHP Bookmarker Tutorial, and have struggled with getting it to work following the instructions outlined on those pages. In this blog, i will outline what steps I need to follow in order to get this to work.

Environment

My environment is as follows:

  • CentOS 6 virtual machine (on VirtualBox)
  • PHP 7.0 (php70u) with Apache 2.2.15 with mod_rewrite

To install CakePHP you will need Composer and also ext-intl. On CentOS, ext-intl is installed using `yum install php70u-intl`.

Installing

To install the project, run this command:

composer self-update && composer create-project --prefer-dist cakephp/app bookmarks

Notice I’ve used a project name of “bookmarks” instead of “bookmarker”.

Creating the Database

To create the database you’ll need to login to MySQL (presumes MySQL is used) and then create the specific database used. Let’s call it “cakedb”. Here is the sequence of commands:

mysql -u username -p
Enter password: userpassword
MariaDB [(none)]> CREATE DATABASE cakedb;
MariaDB [(none)]> USE cakedb;
MariaDB [cakedb]> ALTER DATABASE cakedb CHARACTER SET utf8;

In the above commands, “username” is the MySQL username that can login and create databases. I had to set the character set to UTF-8 so that when creating the tags table, the length of “title VARCHAR(255)” won’t throw an error (ERROR 1071) about the maximum key length.

Run these SQL commands to create the database tables:

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    email VARCHAR(255) NOT NULL,
    password VARCHAR(255) NOT NULL,
    created DATETIME,
    modified DATETIME
);

CREATE TABLE bookmarks (
    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    title VARCHAR(50),
    description TEXT,
    url TEXT,
    created DATETIME,
    modified DATETIME,
    FOREIGN KEY user_key (user_id) REFERENCES users(id)
);

CREATE TABLE tags (
    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255),
    created DATETIME,
    modified DATETIME,
    UNIQUE KEY (title)
);

CREATE TABLE bookmarks_tags (
    bookmark_id INT NOT NULL,
    tag_id INT NOT NULL,
    PRIMARY KEY (bookmark_id, tag_id),
    FOREIGN KEY tag_key(tag_id) REFERENCES tags(id),
    FOREIGN KEY bookmark_key (bookmark_id) REFERENCES bookmarks(id)
);

After creating the tables, exit MySQL:

MariaDB [cakedb]> exit;

Modify Config File

Open the file “config/app.php” and set the database username and password, and database name:

    'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false,
            'host' => 'localhost',
            /**
             * CakePHP will use the default DB port based on the driver selected
             * MySQL on MAMP uses port 8889, MAMP users will want to uncomment
             * the following line and set the port accordingly
             */
            //'port' => 'non_standard_port_number',
            'username' => 'username',
            'password' => 'userpassword',
            'database' => 'cakedb',
            'encoding' => 'utf8',
            'timezone' => 'UTC',
            'flags' => [],
            'cacheMetadata' => true,
            'log' => false,

Generate the Scaffolding Code

From the “bookmarks” directory, run the following commands to create the scaffolding code needed for the application:

bin/cake bake all users
bin/cake bake all bookmarks
bin/cake bake all tags

Once this the above is done, you should be able to start the server. For my setup, the vm I’m using is on a different IP address than my locahost, so I needed to specify a specific IP address and port. This is the command that I ran:

bin/cake -H 192.168.0.100:88

Then in a web browser, enter the URL ‘http://192.168.0.100:88/bookmarks&#8217;.

 

 

Symfony AD Integration

Introduction

Recently, I’ve been investigating Symfony as a solution for a student petitions web application that I’m working on at Taft College. Symfony is a PHP framework that greatly simplifies the creation of web applications. It’s essentially at Model View Controller (MVC) framework.
This blog outlines the enabling of Active Directory integration with Symfony. My reason for documenting it here, was because when I tried searching online for information/examples on how to achieve this, there were references on how to install various components but there were no real step-by-step instructions on how to verify everything it actually working. Hopefully this will help someone else out who is struggling to set this up properly.

Installing Symfony

This blog presumes you have some Linux OS and are using LAMP (Linux Apache MySql/MariaDB PHP) and each of those is configured correctly. You will need to install Symfony and create your Symfony project that you’ll be using to setup the Active Directory integeration. The Symfony Book Installing and Configuring Symfony gives instructions on how to install Symfony (binary) and Composer (you’ll need this too); I recommend to fully go over most of the Symfony Book, as it will help you get familiar with Symfony. Once you’ve created your Symfony project, you can proceed with the next steps.

Install FOSUserBundle

The Friends Of Symfony User Bundle (FOSUserBundle), is a bundle that persists and fetches users in a database. To install it, use composer with the following command within the root of your Symfony web application. For example, let’s presume your apache DocumentRoot is ‘/var/www/html’ and you’ve created your Symfony project application as ‘test’ in the DocumentRoot, then you would run this command under ‘/var/www/html/test’. Run the following command to install FOSUserBundle:

composer require friendsofsymfony/user-bundle “~2.0@dev”

Install PHP LDAP

In this example, I’m using Centos 6. So if you have a different Linux distro, you may have to install with different commands (i.e. rpm, apt-get). Run the following command to install ext-ldap:

yum install php-ldap

There is no post install configuration required.

Install FR3DLdapBundle

The FR3DLdapBundle provide LDAP authentication. To install it, run the following composer command from your Symfony project root:

composer require fr3d/ldap-bundle “3.0.*@dev”

Configuration

You will need to edit a number of files described here to setup the user, security and Active Directory configuration. First, open the file ‘app/AppKernel.php’ and add the FOSUserBundle and FR3DLdapBundle bundles to the registerBundles function:

<?php
 // app/AppKernel.php

public function registerBundles()
 {
   $bundles = [
      // ...
      new FOS\UserBundle\FOSUserBundle(),
      new FR3D\LdapBundle\FR3DLdapBundle(),
      // ...
   ];
 }

Create a file called ‘FOSUser.php’ under ‘src/AppBundle/Entity’. Note: create the Entity directory if it doesn’t exist. Add the following contents to FOSUser.php:

<?php

// src/AppBundle/Entity/FOSUser.php
 namespace AppBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
 use FR3D\LdapBundle\Model\LdapUserInterface;
 use Doctrine\ORM\Mapping as ORM;

/**
   * @ORM\Entity
   * @ORM\Table(name="fos_user")
   */
 class FOSUser extends BaseUser implements LdapUserInterface
 {
 /**
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
 protected $id;

/**
   * @ORM\Column(type="string")
   */
 protected $dn;

public function __construct()
 {
   parent::__construct();
   if (empty($this->roles)) {
      $this->roles[] = 'ROLE_USER';
   }
 }

/**
   * {@inheritDoc}
   */
 public function setDn($dn)
 { $this->dn = $dn; }

/**
   * {@inheritDoc}
   */
 public function getDn()
 { return $this->dn; }
 }

Open the file ‘app/config/routing.yml’ and make the following change:

#    app/config/routing.yml
 ...
 fos_user:
   resource: "@FOSUserBundle/Resources/config/routing/all.xml"

The above setting enables Symfony routing based on configuration from the file vendor/friendsofsymfony/user-bundle/Resources/config/routing/all.xml which enables the routes such as “/login” and “/logout”, providing standard login/logout capability. The Bundle can be overriden but that is not discussed here.

Open the file ‘app/config/security.yml’ and make the following changes. NOTE: This is only my example; Read the Symfony Book > Security section for other examples on how you might configure security for your own scenario. Symfony is highly configurable, and this example is only used as a guideline on helping you to understand how security works in Symfony.

#    'app/config/security.yml'
 # To get started with security, check out the documentation:
 # http://symfony.com/doc/current/book/security.html
 security:
 # Preserve plain text password in token for refresh the user.
 # Analyze the security considerations before turn off this setting.
    erase_credentials: false

encoders:
  FOS\UserBundle\Model\UserInterface: bcrypt

role_hierarchy:
  ROLE_ADMIN:       ROLE_USER
  ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
  chain_provider:
     chain:
        providers: [fos_userbundle, fr3d_ldapbundle]
  fr3d_ldapbundle:
     id: fr3d_ldap.security.user.provider
  fos_userbundle:
     id: fos_user.user_provider.username

firewalls:
 # disables authentication for assets and the profiler, adapt it according to your needs
 dev:
   pattern: ^/(_(profiler|wdt)|css|images|js)/
   fr3d_ldap:  ~
   security: false
   form_login:
     always_use_default_target_path: true
     default_target_path: /profile
   logout:       true
   anonymous:    true

 main:
   pattern: ^/
   fr3d_ldap:  ~
   form_login:
     always_use_default_target_path: true
     default_target_path: /profile
   logout:       true
   anonymous:    true

 access_control:
   - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
   - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
   - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
   - { path: ^/admin/, role: ROLE_ADMIN }

 

Open the file ‘app/config/config.yml’ and add the following lines at the bottom of the file:

#    app/config/config.yml
 ...
 # Friends of Symfony user
 fos_user:
   db_driver: orm
   firewall_name: main
   user_class: AppBundle\Entity\FOSUser

fr3d_ldap:
   driver:
      host: ldap.forumsys.com
   user:
      baseDn: dc=example, dc=com
      attributes:
         - { ldap_attr: uid,  user_method: setUsername }
         - { ldap_attr: mail,  user_method: setEmail }
      filter: (&(ObjectClass=person))

In the above configuration, I’m using the online test LDAP server ‘ldap.forumsys.com’, which is available for anyone to use to test LDAP authentication. Information on this LDAP test server is found at the following web site: http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/

Update Schema

Run the following command from the project root directory:

php bin/console doctrine:schema:update –force

This updates the database schema.

Testing Operation

This section describes the steps needed to verify that the above configuration is actually working and doing what it is supposed to. The key to troubleshooting is checking the ‘var/logs/dev.log’ entries. Since the login page configured is ‘^/login$’, you need to point your browser to your apache Directory path. I’m presuming here that you’ve configured this as your Symfony root/web path (the web folder under your Symfony project root directory). Then in your browser enter the following URL:

http://host.name/app_dev.php/login

Where ‘host.name’ is either an IP address or hostname where your apache web server is running. Notice the path contains ‘app_dev.php’. This is a file located in the web folder. If you are not running your browser on the same host that the apache web server is running on, then you’ll need to open this file and add the IP address of your host machine to the ‘REMOTE_ADDR’ array. NOTE: Only add trusted hosts to the ‘REMOTE_ADDR’ array. The following line shows an example where my host machine has an IP address of ‘192.168.40.208’:

//    web/app_dev.php
 ...
 if (isset($_SERVER['HTTP_CLIENT_IP'])
   || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
   || !(in_array(@$_SERVER['REMOTE_ADDR'], ['192.168.40.208', '127.0.0.1',
   'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
 )

After you browse to the login page, you should should see labels and text fields for entering username and password and a submit button. Enter a username of “riemann” and password of “password”, then click “security.login.submit”, then you should the profile information for the user. Click the “layout.logout” link to logout.

If the login/logout works correctly, then the normal login URL to use is:

http://host.name/login

And to logout, simply use:

http://host.name/logout

 

Getting AD Authentication to Work

Once you have verified the above (verifies LDAP authentication works), then you need to change your “config.yml” to use your Active Directory server. Edit your “config.yml” as follows (the following data is obsfucated):

# FILE: app/config/config.yml
 ...
 fr3d_ldap:
   driver:
      host: my_ad_server.hostname.com
      username: ad_admin_user_account
      password: admin_password
      accountDomainName: DOM.hostname.com
      accountDomainNameShort: DOM # i.e. prefix you use to login.
   user:
      usernameAttribute: sAMAccountName
      baseDn: cn=Users,dc=hostname,dc=com # Use a LDAP browser to verify this.
      filter: (&(ObjectClass=Person))
      attributes:
         - { ldap_attr: samaccountname, user_method: setUsername }
         - { ldap_attr: mail, user_method: setEmail }

You should now be able to login to your Symfony system using your Active Directory accounts. Always start in the dev environment (append ‘app_dev.php’ to URL) to check first that things are working normally, and check the var/logs/dev.log for error messages.

 

Install composer on CentOS 6

I notice that `yum install composer` does not work on CentOS 6, so the following 1 liner command will work instead:

curl -sS https://getcomposer.org/installer | php — –install-dir=/usr/local/bin –filename=composer

Good Starting Point for a .vimrc File

If you are a Linux user, you probably use vim a lot. The “vi” command typically maps to vim. One of the problems with the default setups for most Linux distros is that comments are dark blue and tabs are too large. This post shows a “.vimrc” file that you can simply add to your HOME directory, and then once you use vim, comments will appear in a turquoise (more readable) color and tabs are set to 3 (you can use whatever you like).

To create the .vimrc file simply login to your host and issue the following commands:


cd ~
vi .vimrc

The enter the following code to make the vim changes I describe above:


set encoding=utf-8
set ruler

” Remove distro changes ”
set nocompatible

” Display Line Numbers ”
set number

” Comments color ”
:color desert

” tabs, etc…”
set shiftwidth=3
set softtabstop=3
set expandtab

” Show line end and beginning ”
set listchars=eol:$,tab:>-,trail:.,nbsp:_,extends:+,precedes:+
set list