Pages

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