Sunday 7 January 2018

Zend Framework 2 Create modules tutorial with example

Here are example of Zend Framework 2.5 module.
To run this example you must have already installed Zend Framework 2 in system.
Download the code and put unzipped folder in "modules" folder , then run SQL queries and access with /album/index


Add New Record 
URL: http://example.com/album/add
Add New Record




Listing of Records
URL: http://example.com/album
Listing of Records




Edit the record
URL: http://example.com/album/edit/4

Edit the record




Delete the record
URL: http://example.com/album/album/delete/1

Delete the record




Question: You need following SQL Query?
CREATE TABLE album (
   id int(11) NOT NULL auto_increment,
   artist varchar(100) NOT NULL,
   title varchar(100) NOT NULL,
   PRIMARY KEY (id)
 );
 INSERT INTO album (artist, title)
     VALUES  ('The  Military  Wives',  'In  My  Dreams');
 INSERT INTO album (artist, title)
     VALUES  ('Adele',  '21');
 INSERT INTO album (artist, title)
     VALUES  ('Bruce  Springsteen',  'Wrecking Ball (Deluxe)');
 INSERT INTO album (artist, title)
     VALUES  ('Lana  Del  Rey',  'Born  To  Die');
 INSERT INTO album (artist, title)
     VALUES  ('Gotye',  'Making  Mirrors');



Click below to download the module.
Download the Module



Friday 5 January 2018

How to install Zend Framework2 in Wamp Server window7?

How to install Zend Framework2 in Wamp Server

  1. Go to home directory of wamp (For Example: c://wamp/www
  2. Download composer (If not installed)
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    php composer-setup.php
    php -r "unlink('composer-setup.php');";
    
  3. Download the Zend Framework2
    php composer.phar create-project zendframework/skeleton-application zf2
    
    It will take few mins to download the zend framework.
  4. Copy the composer.phar to zf2 folder
    cp composer.phar zf2
    
  5. Go to zf2 directory
    cd zf2
    
  6. Virtual Host setup
    Add following code in Apache setup
    
    <virtualhost>
        DocumentRoot "D:\wamp\www\zf2\public"
        ServerName zf2.loc
        <directory public="" wamp="" www="" zf2="">
            Options FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
        </directory>
    </virtualhost>