I'm building a website with PHP framework "Slim" as my templating framework, and it recommends using composer as the package manager. SO... I'm now using composer for the first time, developing locally on 64 bit Ubuntu 16.04 and composer is not installing anything into my project.
I've followed the installation instructions on the Slim Framework & Composer websites to a tee.
Basically this is the order of what I've done:
Installed composer into /var/www/html directory [1.]
Created Slim project using Slim-Skeleton as a base
php composer.phar create-project slim/slim-skeleton slimLittleTest
Note: the php composer.phar create-project slim/slim-skeleton command automatically creates a composer.json file, I will put the contents of that file down farther in my question.
Change into that directory and run php composer.phar install
Nothing is installed!
If I try to run php -S localhost:8080 -t public public/index.php as you're now supposed to able to (from the Slim framework website homepage tutorial) I get the following error:
[Tue Sep 5 18:55:04 2017] PHP Fatal error: require(): Failed opening required '/var/www/html/slimLittleTest/public/../vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/html/slimLittleTest/public/index.php on line 12
[Tue Sep 5 18:55:05 2017] PHP Warning:
require(/var/www/html/slimLittleTest/public/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/slimLittleTest/public/index.php on line 12
This error of course makes sense because nothing got installed! There is no vendor/autoload.php because Composer hasn't installed anything. (By default Composer installs dependencies into the vendor folder in the root of your project)
SEPTEMBER 7th QUESTION UPDATE
From some comments down below, I've been alerted to the fact that something must have gone wrong on the command composer create-project, that my solution of just re-requiring all packages shouldn't be necessary. Upon further inspection, I did get some errors upon running command php composer.phar create-project slim/slim-skeleton projectName. Below is exactly what got output from the console after running that command:
php composer.phar create-project slim/slim-skeleton tester
Installing slim/slim-skeleton (3.1.2)
- Installing slim/slim-skeleton (3.1.2): Loading from cache
Created project in tester
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/phpunit 5.7.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 5.7.8 requires ext-dom * -> the requested PHP extension dom is missing from your system.
- phpunit/phpunit 5.7.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
[.......]
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-curl.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-imagick.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-mbstring.ini
- /etc/php/7.0/cli/conf.d/20-mcrypt.ini
- /etc/php/7.0/cli/conf.d/20-mysqli.ini
- /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Would either that .ini extensions issue or Problem 1 php unit requires ext-dom issue be the main source of my problem?
I got lucky and stumbled upon an answer that worked in my situation.
I just had to run php composer.phar require [package_name], for each package name, and if it wasn't in composer.json yet that dependency would get installed. So what I needed to do was delete the composer.json file, then go back and require each package from it. Nothing else worked, such as php composer.phar update, or php composer.phar install.
So I ran php composer.phar require slim/php, php composer.phar require php, etc. from the command line and everything installed correctly.
This is potentially a failure of the getting started documentation from SlimFramework.com, It's not necessarily "wrong" because maybe it works in some/most situations, but they should at least address the potential for the problem I ran into, and a solution or way to avoid it.
EVEN BETTER SOLUTION
Turns out that the main error I was getting here is that I was missing ext-dom. Thank you to this badass #Anar Bayramov's answer on another StackOverflow question I know that I can get the missing ext-dom by simply downloading php7.0-xml.
sudo apt-get update
sudo apt-get install php7.0-xml
And BOOM! Now when I run php composer.phar create-project slim/slim-skeleton projectName all vendor packages are installed successfully and it works like a charm. Problem solved.
Related
I've dug through a few of the other answers here and nothing seems to fit the bill. I'm probably going to leave some information out initially so just let me know what else you might need and thanks!
Currently running ubuntu 7, using composer and laravel both of which seem to be installed properly:
When I type 'php artisan serve' and 'php artisan serve --port:8000' into terminal I get this error:
PHP Warning:
require(/home/user/Projects/thingy/bootstrap/../vendor/autoload.php):
failed to open stream: No such file or directory in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17 PHP
Fatal error: require(): Failed opening required
'/home/user/Projects/thingy/bootstrap/../vendor/autoload.php'
(include_path='.:/usr/share/php') in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17
When I attempt to run 'php -S localhost:8000 -t public/' just as an attempt I get the following error upon refresh:
PHP 7.0.18-0ubuntu0.17.04.1 Development Server started at Thu Jul 6
09:15:36 2017 Listening on http://localhost:8000 Document root is
/home/user/Projects/thingy/public Press Ctrl-C to quit. [Thu Jul 6
09:15:40 2017] PHP Warning:
require(/home/user/Projects/thingy/bootstrap/../vendor/autoload.php):
failed to open stream: No such file or directory in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17 [Thu
Jul 6 09:15:40 2017] PHP Fatal error: require(): Failed opening
required
'/home/user/Projects/thingy/bootstrap/../vendor/autoload.php'
(include_path='.:/usr/share/php') in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17 [Thu
Jul 6 09:15:40 2017] 127.0.0.1:57214 [500]: / - require(): Failed
opening required
'/home/user/Projects/thingy/bootstrap/../vendor/autoload.php'
(include_path='.:/usr/share/php') in
/home/user/Projects/thingy/bootstrap/autoload.php on line 17
I checked to see if maybe a server was already running using the 'ps -ef | grep php' command in terminal and I don't see any servers running at all.
I have run 'composer install' and I get the following error:
Cannot create cache directory
/home/user/.composer/cache/repo/https---packagist.org/, or directory
is not writable. Proceeding without cache Cannot create cache
directory /home/user/.composer/cache/files/, or directory is not
writable. Proceeding without cache Cannot create cache directory
/home/user/.composer/cache/repo/https---packagist.org/, or directory
is not writable. Proceeding without cache Loading composer
repositories with package information Installing dependencies
(including require-dev) from lock file Your requirements could not be
resolved to an installable set of packages.
Problem 1
- Installation request for laravel/framework v5.4.28 -> satisfiable by laravel/framework[v5.4.28].
- laravel/framework v5.4.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
Problem 2
- Installation request for phpunit/php-code-coverage 4.0.8 -> satisfiable by phpunit/php-code-coverage[4.0.8].
- phpunit/php-code-coverage 4.0.8 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 3
- Installation request for phpunit/phpunit 5.7.21 -> satisfiable by phpunit/phpunit[5.7.21].
- phpunit/phpunit 5.7.21 requires ext-dom * -> the requested PHP extension dom is missing from your system. Problem 4
- laravel/framework v5.4.28 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/tinker v1.0.1 requires illuminate/console ~5.1 -> satisfiable by laravel/framework[v5.4.28].
- Installation request for laravel/tinker v1.0.1 -> satisfiable by laravel/tinker[v1.0.1].
To enable extensions, verify that they are enabled in your .ini
files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-pdo_pgsql.ini
- /etc/php/7.0/cli/conf.d/20-pgsql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
- /etc/php/7.0/cli/conf.d/20-zip.ini You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.
When running 'composer dump-autoload' I get the following:
Cannot create cache directory
/home/user/.composer/cache/repo/https---packagist.org/, or directory
is not writable. Proceeding without cache Cannot create cache
directory /home/user/.composer/cache/files/, or directory is not
writable. Proceeding without cache Cannot create cache directory
/home/user/.composer/cache/repo/https---packagist.org/, or directory
is not writable. Proceeding without cache Generating optimized
autoload files
After following the advice of Nishan Karunarathna and Alex I now get the following error when I run 'php artisan serve':
PHP Fatal error: Uncaught Error: Class
'Illuminate\Foundation\Application' not found in
/home/joshua/Projects/thingy/bootstrap/app.php:14 Stack trace:
0 /home/joshua/Projects/thingy/artisan(18): require_once()
1 {main} thrown in /home/joshua/Projects/thingy/bootstrap/app.php on line 14
Thanks for any help you give!
You have sort out the errors when encountered when doing composer install.
Install required PHP extensions
sudo apt-get install php7.0-mbstring
sudo apt-get install php7.0-xml
Then restart your nginx and try to run composer install again.
I think you should:
1) Install additional php extensions. Run into your terminal something like:
$ sudo apt-get install php7.0-opcache php7.0-calendar php7.0-ctype php7.0-gettext ...
2) Then give permissions to cache dir of composer:
$ sudo chmod -R u+w /home/joshua/.composer or if this directory is absent your should create its before $ sudo mkdir /home/joshua/.composer
3) Run $ composer install
But I'd like to pay your attention on:
1) Check your home directory on write permissions. If you don't have them, the most part of programs can't work correctly
2) Probably you have needed php extensions but they are not loaded. In this case check your .ini files and enable extensions.
Ok so I managed to answer my own question (actually a friend answered it for me.)
Apparently after you install laravel and composer it can, on occasion, lose the file path:
I had to open my .bashrc file in my hidden files on the /home/user/ level and add the command 'export PATH=~/.composer/vendor/bin:$PATH'
I think the other users here did contribute to fixing my problem as laravel and composer didn't seem to be installed correctly despite the files being in the proper place.
When I install Zend via composer create-project -n -sdev zendframework/skeleton-application as specified by Zend's main tutorial, I get a skeleton application that seems to work nicely.
However, when I follow this tutorial's advice to use composer development-enable, I get the following message:
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "development-enable" is not defined.
Is anyone able to duplicate/fix this problem?
I would normally assume it's an issue with the bash $PATH value, but the composer command by itself runs just fine, so I'm thinking it may be some other problem specific to this subcommand -- a missing dependency somewhere, for example.
Here is the relevant piece of the tutorial I am trying to follow:
https://docs.zendframework.com/tutorials/getting-started/skeleton-application/
(In case it helps for purposes of duplication: The CLI PHP version on my development server is 5.4.43. For reasons I won't bore you with, I can't update this CLI PHP to a newer version; the major release that Apache is using on my machine is 5.6.)
EDIT 1: Rerunning my installation using composer create-project -s dev zendframework/skeleton-application (as specified in the linked tutorial) still results in the same problem.
EDIT 2: Here is my shell input/output.
patrick [~/www/berlin-data]# composer create-project -n -sdev zendframework/skeleton-application
Installing zendframework/skeleton-application (2.3.3)
- Installing zendframework/skeleton-application (2.3.3)
Loading from cache
Created project in /home1/patrick/public_html/berlin-data/skeleton-application
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing zendframework/zendxml (1.0.2)
Loading from cache
- Installing zendframework/zendframework (2.3.3)
Loading from cache
zendframework/zendframework suggests installing doctrine/annotations (Doctrine Annotations >=1.0 for annotation features)
zendframework/zendframework suggests installing ircmaxell/random-lib (Fallback random byte generator for Zend\Math\Rand if OpenSSL/Mcrypt extensions are unavailable)
zendframework/zendframework suggests installing ocramius/proxy-manager (ProxyManager 0.5.* to handle lazy initialization of services)
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)
Writing lock file
Generating autoload files
patrick [~/www/berlin-data]# cd skeleton-application/
patrick [~/www/berlin-data/skeleton-application]# composer development-enable
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "development-enable" is not defined.
When you run the command
composer create-project -n -sdev zendframework/skeleton-application
This will create a directory in your current dir called skeleton-application inside of this directory is where you need to run the command:
composer development-enable
If this still doesnt work then something went wrong with install process.
The first command should give out put something like:
$ composer create-project -n -sdev zendframework/skeleton-application
Installing zendframework/skeleton-application (dev-master 941da45b407e4f09e264f0 00fb537928badb96ed)
- Installing zendframework/skeleton-application (dev-master master)
Cloning master from cache
Created project in C:\Users\<UserName>\Documents\skeleton-application
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
- Installing zendframework/zend-component-installer (0.3.0)
Downloading: 100%
- Installing zendframework/zend-stdlib (3.0.1)
Downloading: 100%
...
Notice this line Created project in C:\Users\<UserName>\Documents\skeleton-application
Thats the directory you need to be in to run the command:
cd C:\Users\<UserName>\Documents\skeleton-application
composer development-enable
If that still didnt work, try specifying the version for downloading:
composer create-project -n "zendframework/skeleton-application":"dev-master"
PS
As of writing this the skeleton application requires PHP "^5.6 || ^7.0". So if you are running a lower version composer wont install that copy. And the tutorials based on it may not work as expected.
Two things I've noticed: when you first initialize a skeleton application, depending on your settings, development mode is enabled by default.
If you want to run
composer development-enable
or any other similar commands, you must be in your path/to/install or path/to/yourapp directory for it to work! This is the folder that contains your local composer install. If you are in any of the parent directories, the command will not work.
I was also having this similar problem when trying to enable development mode with the command composer development-enable on my apigility app. I was getting error:
zf-development-mode is not recognised as an internal or external command.
There is a page on the apigility website regarding the development mode module:
https://apigility.org/documentation/modules/zf-development-mode
I found by following the instruction to install the module from composer:
$ composer require zfcampus/zf-development-mode
Then making a copy of the development config file:
$ cp vendor/zfcampus/zf-development-mode/development.config.php.dist config/
Now using the composer development-enable seems to work fine, which in my case returned the message 'Already in development mode'.
I need help with creating a symfony project in ubuntu/eclipse i get a lot of warnings. i Use:
ubuntu: 15.04
eclipse: 4.5.0 mars
symfony feature: 1.1.0.20150705
I use Symfony Feature to create projects using a built in wizard.
Project details:
PHP version: 5.6
Symfony version: v2.7.3
Override composer.jason values: i use defaults
i get errors with app/bootstrap.php.cache
Maybe there is a good tutorial that might help me, but 'till now i haven't found one...
Maybe elipse isn't good for symfony project.
Here are some error messages:
!ENTRY com.dubture.composer.core 4 4 2015-08-06 20:49:38.196
!MESSAGE PHP Warning: require_once(/var/www/test3/app/bootstrap.php.cache): failed to open stream: No such file or directory in /var/www/test3/app/console on line 10
PHP Fatal error: require_once(): Failed opening required '/var/www/test3/app/bootstrap.php.cache' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/test3/app/console on line 10
and second
!ENTRY com.dubture.composer.core 4 4 2015-08-06 20:50:29.267
!MESSAGE Installing symfony/framework-standard-edition (v2.7.2)
- Installing symfony/framework-standard-edition (v2.7.2)
Loading from cache
Created project in test1
> SymfonyStandard\Composer::hookRootPackageInstall
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for sensiolabs/security-checker v2.0.5 -> satisfiable by sensiolabs/security-checker[v2.0.5].
- sensiolabs/security-checker v2.0.5 requires ext-curl * -> the requested PHP extension curl is missing from your system.
Problem 2
- sensiolabs/security-checker v2.0.5 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- sensio/distribution-bundle v4.0.0 requires sensiolabs/security-checker ~2.0 -> satisfiable by sensiolabs/security-checker[v2.0.5].
- Installation request for sensio/distribution-bundle v4.0.0 -> satisfiable by sensio/distribution-bundle[v4.0.0].
thats a piece of the whole log file, those are the messages i get in gui.
Composer installation failed with an error (see second set of error messages) because it could not install all dependencies.
It says in the error message:
the requested PHP extension curl is missing from your system.
You need to install this extension for PHP to get all required files to get your project up and running.
When Symfony2 starts up, it need some of bootstrap cookies which will be removed, eventually. From my experience, 'bootstrap.php.cache' file existed for ACME bundle example pages, and It is not essential file.
The solution is simple.
You just need to create 'bootstrap.php.cache' file in /var/www/test3/app/ folder. The content of 'bootstrap.php.cache' can be blank.
touch bootstrap.php.cache
Hope this works well for you. Good luck!
It's possible that, you don't have right permission for read in these file, check this sudo chmod 755 in these file. If you haven't that file, create it how suggests YONGSOO KIM
The solution is simple. You just need to create bootstrap.php.cache
file in /var/www/test3/app/ folder. The content of bootstrap.php.cache
can be blank.
You can fix problem with versions of package sensiolabs/security-checker or generate bootstrap cache file like answer here https://stackoverflow.com/a/6884027/4356973
I'm running a vagrant box w/ a simple lamp stack. I've installed phpunit globally via composer :
composer global require "phpunit/phpunit=4.1.*"
When I run phpunit I get the following error:
PHP Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/share/php/PHPUnit/Autoload.php on line 46
HP Fatal error: require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='/home/vagrant/.composer/vendor/phpunit/php-text-template:/home/vagrant/.composer/vendor/phpunit/phpunit-mock-objects:/home/vagrant/.composer/vendor/phpunit/php-timer:/home/vagrant/.composer/vendor/phpunit/php-token-stream:/home/vagrant/.composer/vendor/phpunit/php-file-iterator:/home/vagrant/.composer/vendor/phpunit/php-code-coverage:/home/vagrant/.composer/vendor/phpunit/phpunit:/home/vagrant/.composer/vendor/symfony/yaml:.:/usr/share/php:/usr/share/pear') in /usr/share/php/PHPUnit/Autoload.php on line 46
My research seems to imply that it's a problem with CodeCoverage not installing, but I'm having problems trying to get that installed. I've tried to install via composer and can't get it working.
Via Composer, I've tried adding to the global:
composer global require "phpunit/php-code-coverage": "3.0.*#dev"
and I get this output:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package phpunit/php-code-coverage could not be found in any version, there may be a typo in the package name.
Problem 2
- phpunit/phpunit 4.1.3 requires phpunit/php-code-coverage ~2.0 -> no matching package found.
- phpunit/phpunit 4.1.3 requires phpunit/php-code-coverage ~2.0 -> no matching package found.
- Installation request for phpunit/phpunit == 4.1.3.0 -> satisfiable by phpunit/phpunit[4.1.3].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Installation failed, reverting ./composer.json to its original content.
No clue what I'm doing wrong!
you need to reinstall code-coverage 2.0 first
composer global require "phpunit/php-code-coverage":"2.0.*#dev"
then you install phpunit
composer global require "phpunit/phpunit=4.1.*"
I'm new to Yii2, now I'm trying to install yii2 application advanced template.
I did follow these steps:
1 - Download yii2-app-advanced zip file from https://github.com/yiisoft/yii2-app-advanced
2 - Follow GETTING STARTED guide:
+ I'm using Uniform Zero Server (installed in F disk with the path "F:\Server\UniServerZ\www") ok.
+ I creted new folder with name "yii2" in the "www" directory ("F:\Server\UniServerZ\www\yii2")
+ I extracted zip file yii2-app-advanced into "yii2" folder (Every source of yii2-app-advanced now in "yii2" folder so it is the root directory of yii2-app-advanced)
+ Click init.bat file to run "init" and select (0 - Developer mode) and type "yes" to confirm. Done
+ And then I click the yii.bat file, but nothing happened.
+ I tried use this url : localhost/yii2/backend/web/
And I get this Error:
Fatal error: require(): Failed opening required 'F:\Server\UniServerZ\www\yii2\backend\web/../../vendor/autoload.php' (include_path='.;F:/Server/UniServerZ/home/us_pear/PEAR') in F:\Server\UniServerZ\www\yii2\backend\web\index.php on line 5
or url : localhost/yii2/frontend/web/
And I get this Error too:
Fatal error: require(): Failed opening required 'F:\Server\UniServerZ\www\yii2\frontend\web/../../vendor/autoload.php' (include_path='.;F:/Server/UniServerZ/home/us_pear/PEAR') in F:\Server\UniServerZ\www\yii2\frontend\web\index.php on line 5
I checked the "vendor" directory follow this path:
F:\Server\UniServerZ\www\yii2\vendor
But it's empty.
So what should I do to fix this error and install yii2 application advanced template?
(My Uniform Server runs PHP5.4)
Yii2 Installation Following command:
(1) First install Composer (LINUX):
Locally:
curl -sS https://getcomposer.org/installer | php
OR
(1) First install Composer (WINDOWS):
C:\Users\username>cd C:\bin
C:\bin>php -r "readfile('https://getcomposer.org/installer');" | php
Note: If the above fails due to readfile, use the http url or enable php_openssl.dll in php.ini
C:\bin>echo #php "%~dp0composer.phar" %*>composer.bat
C:\Users\username>composer -V
Composer version 27d8904
(2) Yii2 framework online downloads:
Basic App:
php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.0-beta
Advanced App:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.0-beta
(3) Other App Settings Command:
php init
php yii migrate
If you are working on linux, go to the downloaded project and in the terminal type (if you have a composer):
php composer.phar install
If the composer is not installed go to https://getcomposer.org/download/ After this, yii2 framework and other extensions will be installed at vendor directory. This should fix the problem
Install with composer :
D:\wamp\www> composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced D:\wamp\www\myyii2app
and run php ./init
D:\wamp\www\myyii2app>php ./init
Under Linux, cd to the directory of the downloadable project using Terminal and run the following commands:
$ php init --env=Development
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar update
Installing using Composer
If you do not have Composer, follow the instructions in the Installing Yii section of the definitive guide to install it.
With Composer installed, you can then install the application using the following commands:
composer global require "fxp/composer-asset-plugin:~1.1.1"
composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application
The first command installs the composer asset plugin which allows managing bower and npm package dependencies through Composer. You only need to run this command once for all. The second command installs the advanced application in a directory named yii-application. You can choose a different directory name if you want.
Install from an Archive File
Extract the archive file downloaded from yiiframework.com to a directory named advanced that is directly under the Web root.
Then follow the instructions given in the next subsection.
Preparing application
After you install the application, you have to conduct the following steps to initialize the installed application. You only need to do these once for all.
Execute the init command and select dev as environment.
php /path/to/yii-application/init
Otherwise, in production execute init in non-interactive mode.
php /path/to/yii-application/init --env=Production --overwrite=All
Create a new database and adjust the components['db'] configuration in common/config/main-local.php accordingly.
Apply migrations with console command yii migrate.
A php component might be missing, i installed mbstring, then restarted the whole process.
yum -y install php54w_mbstring
composer init
composer create-project --prefer-dist
--stability=dev yiisoft/yii2-app-basic <project-name>
****To install YII2-Advance use these command at your CMD. And see bellow...........****
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.
C:\Users\admin>e: (RUN COMMAND)
E:>cd xampp/htdocs (RUN COMMAND)
E:\xampp\htdocs>composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application (RUN COMMAND)
Installing yiisoft/yii2-app-advanced (2.0.9)
- Installing yiisoft/yii2-app-advanced (2.0.9)
Loading from cache
Created project in yii-application
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing yiisoft/yii2-composer (2.0.4)
Downloading: 100%
Installing swiftmailer/swiftmailer (v5.4.3)
Downloading: 100%
Installing bower-asset/jquery (2.2.4)
Downloading: 100%
Installing bower-asset/yii2-pjax (v2.0.6)
Downloading: 100%enter code here
Installing bower-asset/punycode (v1.3.2)
Downloading: 100%
Installing bower-asset/jquery.inputmask (3.2.7)
Downloading: 100%
Installing cebe/markdown (1.1.0)
Downloading: 100%
Installing ezyang/htmlpurifier (v4.8.0)
Downloading: 100%
Installing yiisoft/yii2 (2.0.9)
Downloading: 100%
Installing yiisoft/yii2-swiftmailer (2.0.5)
Downloading: 100%
Installing yiisoft/yii2-codeception (2.0.5)
Downloading: 100%
Installing bower-asset/bootstrap (v3.3.7)
Downloading: 100%
Installing yiisoft/yii2-bootstrap (2.0.6)
Downloading: 100%
Installing yiisoft/yii2-debug (2.0.6)
Downloading: 100%
Installing bower-asset/typeahead.js (v0.11.1)
Downloading: 100%
Installing phpspec/php-diff (v1.1.0)
Downloading: 100%
Installing yiisoft/yii2-gii (2.0.5)
Downloading: 100%
Installing fzaninotto/faker (v1.6.0)
Downloading: 100%
Installing yiisoft/yii2-faker (2.0.3)
Downloading: 100%
Writing lock file
Generating autoload files
E:\xampp\htdocs>cd yii-application (RUN COMMAND)
E:\xampp\htdocs\yii-application>php init (RUN COMMAND)
Yii Application Initialization Tool v1.0
Which environment do you want the application to be initialized in?
[0] Development
[1] Production
Your choice [0-1, or "q" to quit] 0 (Enter with 0 RUN COMMAND)
Initialize the application under 'Development' environment? [yes|no] yes (Enter with yes RUN COMMOND)
Start initialization ...
... initialization completed.
E:\xampp\htdocs\yii-application>yii migrate (RUN COMMOND)
Yii Migration Tool (based on Yii v2.0.9)
Creating migration history table "migration"...Done.
Total 1 new migration to be applied:
m130524_201442_init
Apply the above migration? (yes|no) [no]:yes
*** applying m130524_201442_init
create table {{%user}} ... done (time: 0.225s)
*** applied m130524_201442_init (time: 0.310s)
1 migration was applied.
Migrated up successfully.
Finally created yii-application folder in htdocs
E:\xampp\htdocs\yii-application>
If you want to install Yii2 advanced template go to http://www.yiiframework.com/download/ and download the Yii 2 with advanced application template. Once you have extracted the archive file in the www folder.
Then Go to Terminal(For Ubuntu) or cmd(Windows user)
For Ubuntu-
provide root to the extracted folder(advanced) in the Terminal
cd var/www/html/ashish/advanced
Now give the commond- php init
Now advance template is installed properly