How to setup First Application in Zend Framework 2

2019-02-04 09:32发布

i am creating my first application in zf2. i followed Zend Offical website zf2 Skeleton Application.i have downloaded the skeleton app from github as in in the given link.when i extract it and put that in my folder and run it its showing this Fatal Error

 Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to load ZF2. 
 Run  `php composer.phar install` or define a ZF2_PATH environment variable.' in 
 D:\projects\zf2\zf2_app\init_autoloader.php:50 Stack trace: #0 D:\projects\zf2\zf2_app
 \public\index.php(9): require() #1 {main} thrown in D:\projects\zf2\zf2_app
 \init_autoloader.php on line 50

i dont know How to fix this??

and what about this?

To install Zend Framework 2 into our application we simply type:
  php composer.phar self-update
  php composer.phar install

where to type these commands? Help me with my first ZF2 app

7条回答
萌系小妹纸
2楼-- · 2019-02-04 09:38

In addition to Rob Allens answer i have good responses so far from Windows User who have less experience with the command line.

You may find my blog helpful, too: Zend Framework 2 installation on Xampp for Windows

查看更多
不美不萌又怎样
3楼-- · 2019-02-04 09:42

its seems like you have not Downloaded the zf2 :) download it from here http://framework.zend.com/downloads/latest#ZF2

extract the framework to vendor/ZF2. and you done :) now browse to your app hope it showing No Exception.

查看更多
相关推荐>>
4楼-- · 2019-02-04 09:42

As you have already downloaded the GIT file Below commands are for windows :

1) Go to the respective folder 2) run the command -> composer update 3) That should let you install and choose optional modules 4) Finally -> php -S 0.0.0.0:8080 -t .\public .\public\index.php

With this you should be able to access the index page at http://localhost:8080/

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-02-04 09:50

How about making it easier @Rob Allen? When answering, so that other reader can save 24 hours to 1 minute !! I tried to make it easier from your answer as below:

1) httpd.conf
<VirtualHost *:80>
 ServerName site
 ServerAlias site
 DocumentRoot /var/www/html/s/public
 <Directory /var/www/html/s/public>
    #AddDefaultCharset utf-8
    DirectoryIndex index.php
    AllowOverride FileInfo
    Order allow,deny
    Allow from all
 </Directory>
</VirtualHost>

2) i did git clone git repo
$ ls
composer.json  composer.lock  composer.phar  config  data  db_bck  init_autoloader.php  LICENSE.txt  module  nbproject  public  README.md  vendor

3) I run and i get same error

4) I did now this

$ php composer.phar install
Loading composer repositories with package information
Installing dependencies from lock file
  - Installing zendframework/zendframework (2.0.6)
    Downloading: 100%         

    Skipped installation of bin/classmap_generator.php for package zendframework/zendframework: name conflicts with an existing file
zendframework/zendframework suggests installing doctrine/common (Doctrine\Common >=2.1 for annotation features)
zendframework/zendframework suggests installing ext-intl (ext/intl for i18n features)
zendframework/zendframework suggests installing pecl-weakref (Implementation of weak references for Zend\Stdlib\CallbackHandler)
zendframework/zendframework suggests installing zendframework/zendpdf (ZendPdf for creating PDF representations of barcodes)
zendframework/zendframework suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha for rendering ReCaptchas in Zend\Captcha and/or Zend\Form)
Generating autoload files


5) It works now
查看更多
闹够了就滚
6楼-- · 2019-02-04 09:54

You may want to follow the following steps:

  1. Download ZF2 Skeleton Application from Github.

  2. Change directory where you want to install, and unzip the skeleton application.

  3. Change directory to "ZendSkeletonApplication-master", and run the following:

    php composer.phar self-update
    php composer.phar install

查看更多
倾城 Initia
7楼-- · 2019-02-04 09:58

You should open a cmd window and change directory to your project. You then need to type the following:

php composer.phar install

This will install all the library dependencies for the Zend Skeleton Application - ZF2 in this case.

查看更多
登录 后发表回答