Posts

Showing posts from November, 2012

Install CakePHP 4.x in Ubuntu

Image
Installation CakePHP has a few system requirements: HTTP Server. For example: Apache. Having mod_rewrite is preferred, but by no means required. You can also use nginx, or Microsoft IIS if you prefer. Minimum PHP 7.2 ( 8.1  supported). mbstring PHP extension intl PHP extension SimpleXML PHP extension PDO PHP extension In XAMPP, intl extension is included but you have to uncomment  extension=php_intl.dll  (or  extension=intl ) in  php.ini  and restart the server through the XAMPP Control Panel. In WAMP, the intl extension is “activated” by default but not working. To make it work you have to go to php folder (by default)  C:\wamp\bin\php\php{version} , copy all the files that looks like  icu*.dll  and paste them into the apache bin directory  C:\wamp\bin\apache\apache{version}\bin . Then restart all services and it should be OK. While a database engine isn’t required, we imagine that most applications will utilize one. CakePHP supports a variety of database storage engines: MySQL (5.6

ACL 2.2.0 Plugin for CakePHP 2.2.3

Image
This plugin is such an interface allowing to manage permissions of your application's users and roles. 1. Download latest CakePHP latest stable in CakePHP.org. 2. Install CakePHP see how: Install CakePHP 2.x in Ubuntu. 3. Setup a Simple Acl Controlled Application follow instruction here : Simple  Acl Controlled Application , part 1 only. 4. Download ACL Plugin for CakePHP 2.2 ACL Plugin Installation copy the folder acl in your folder /app/plugins configure the admin route (see http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing ) copy the parameters found in Acl/Config/bootstrap.php in your file /app/Config/bootstrap.php or load the plugin with its own bootstrap.php file CakePlugin::load ( 'Acl' , array( 'bootstrap' => true )); see more: ACL Plugin Installation  5. In your bootstrap.php located in your cakefolder/app/Plugin/Acl/Config/bootsrap.php. If you use groups (if you use database in in simple acl controlle

CakePHP: GET Current Controller, Action and Parameters

Image
Request Parameters To get the current controller: $controllerName = $this -> request -> getAttribute ( 'controller' ); To get the current action: $acctionName = $this -> request -> getAttribute ( 'action' ); To get all passed arguments as a numerically indexed array: http :// localhost / calendars / view / recent / mark $parameters = $this -> request -> getParam( 'pass' ); Array ( [ 0 ] => recent [ 1 ] => mark ) Query String Parameters // URL is /posts/index?page=1&sort=title $page = $this -> request -> getQuery ( 'page' );

CakePHP : Accessing the logged in user

Once a user is logged in, you will often need some particular information about the current user. You can access the currently logged in user using  AuthComponent::user() . This method is static, and can be used globally after the AuthComponent has been loaded. You can access it both as an instance method or as a static method: You can access all the user's information(fields) from the users table except the password. <?php // Use anywhere  // Accesing user’s id AuthComponent :: user ( 'id' );                                                                 $_SESSION[' Auth '][' User' ][' id ']; // Accesing user’s username AuthComponent :: user ( 'username' );                                                                 $_SESSION[' Auth '][' User' ][' username ']; // Accesing user’s group_id AuthComponent :: user ( 'group_id' );