Pages

Sunday, December 27, 2015

Symfony-Generate Bundle Option not working in app/console

Recently in One of the symfony dumps I gathered from my IT team had an issue due to some reason "Generate Bundle" option was not working from app/console list -- raw

Solution :

Add following lines in File composer.json

"required-dev":{
"sensio/generator-bundle": "~2.3"
}

File AppKernal.php should have

new Sensio\Bundle\GeneratorBundle\SensioGenerator();

That's it

Thursday, July 30, 2015

Cakephp 2.0-Validations not working

Many a times Our custom Validations do not work in cakephp due to very tiny small errors.Here is a piece of my research and development which might help you
 In the controller
       if (!empty($this->data))   
       {  
         $this->User->set($this->data);  
         if ($this->User->validates())   
         {  
           // it validated logic  
           echo "Yes we can proceed";  
         }   
         else   
         {  
           // didn't validate logic  
           $errors = $this->User->validationErrors;  
           pr($errors);  
         }  
       }  

See the line in Bold this must be done to get errors set

In the view
   <?php   
       if($this->Form->isFieldError('User.username'))  
       {  
         echo $this->Form->error('User.username', null, array('class' => 'message'));   
       }  
       ?>  
Now set the class to taste and you will get error message in view in desired color.

Thursday, July 9, 2015

Cakephp 2.0-Adding favicon to your website

I was able to add a favicon to my website using code mentioned.This one is trusted and working.

 echo $this->Html->meta('favicon.ico','img/favicon.ico',array('type' => 'icon'));  

You need to place your favicon.ico file in/webroot/img directory

Sunday, April 5, 2015

Cakephp 3.0-Where IN Condition with list

So here comes Cakephp 3.0 with all new syntax new ORM and many other changes.I find myself struggling with Cakephp this hard since I used cakephp 1.3 for the first time.

But here is My first struggle to help you with

  return $this->find('list',['keyField' => 'id', 'valueField' => 'name'])->where([  
          'id IN'=>$nearCitys  
       ])->toArray();  

Saturday, April 4, 2015

Cakephp 3.0-Installing from Composer

Recently I was trying to install cakephp 3.0 from composer which was throwing some cache errors as such my install was unsuccessfull

Here is what I did to correct the same

When you run composer to install something let us suppose cakephp 3.0 it creates a cache in your home directory.In my case location was

/home/gaurav/.composer

 This location has a cache folder which works for composer installation.This is not writable by default so this should b provided write permissions also Cakephp 3.0 requires
  • mbstring extension
  • intl extension
which must be installed in advanced(google it to get concerned installation repository for your distribution)

After that my Install went smooth.

Apache2-Forbidden You don't have permission to access /dir/ on this server

Recently on restarting my Apache Server on Ubuntu I came across following error

Forbidden You don't have permission to access /dir/ on this server

After a bit of google I solved this by granting permissions to my server directory and resetting my httpd.conf directory access levels as follows

Since I am working on Ubuntu I will be using Ubuntu locations your locations can very depending upon your linux distribution

In Ubuntu httpd.conf file is place under
/etc/apache2/sites-available directory

if you list directory contents you will find files like

000-default.conf   000-default.old   example.com~
000-default.conf~  default-ssl.conf

Out of these first one is the httpd.conf file in concern(this is how Ubuntu stores it)

First make a copy of the same as you can see I have made a copy of the same 000-default.old using following command

sudo cp 000-default.conf 000-default.old

Now Alter the 000-default.conf as follows

 <VirtualHost *:80>  
   ServerAdmin webmaster@localhost  
   DocumentRoot /var/www  
   <Directory />  
     Options FollowSymLinks  
     AllowOverride None  
   </Directory>  
   <Directory /var/www>  
     Options Indexes FollowSymLinks MultiViews  
     AllowOverride All  
     Order allow,deny  
     allow from all  
   </Directory>  
   ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/  
   <Directory "/usr/lib/cgi-bin">  
     AllowOverride None  
     Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch  
     Order allow,deny  
     Allow from all  
   </Directory>  
   ErrorLog ${APACHE_LOG_DIR}/error.log  
   # Possible values include: debug, info, notice, warn, error, crit,  
   # alert, emerg.  
   LogLevel warn  
   CustomLog ${APACHE_LOG_DIR}/access.log combined  
 </VirtualHost>  

Next grant permissions to your directory as

sudo chown -R $USER:$USER /var/www
sudo chmod -R g+rw /var/www
 
You will now be able to access your localhost directory 
 

Wednesday, March 25, 2015

Configuring External Apache Tomcat in Netbeans/Ubuntu or error : specify the server location (Catalina Home)) and error : could not read server-config.xml

Hi This posts counters the problem of configuration of external Apache Tomcat Server to Ubuntu..

It also deals with the errors
1. specify the server location (Catalina Home))
2. could not read server-config.xml

To Counter all this we need to do as follows

For First Problem create and link directories as follows.This will only occur if Netbeans thinks if you are using and older version of Tomcat Server.

cd /usr/share/tomcat7
sudo mkdir common
cd common
sudo ln -s ../lib lib

For Second Problem create and link directories as follows

cd /usr/share/tomcat7
sudo mkdir conf 
cd conf
sudo ln -s /etc/tomcat7/server.xml server.xml
sudo chmod o+rx /usr/share/tomcat7/conf 
 
Thats it give a username and Password and Apache server is configured on your Netbeans