Can't install Yii2 via Composer - yii2

I'm trying to install Yii2 via Composer (OS X El Capitan 10.11.3).
I did this
php composer.phar global require "fxp/composer-asset-plugin:~1.1.1"
and then
php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.9
and I've got errors like
yiisoft/yii2 2.0.9 requires bower-asset/jquery 2.2.#stable | 2.1.#stable | 1.11.#stable | 1.12.#stable -> no matching package found.
I don't know why it happens. I tried to reinstall (composer and asset-plugin), diff version as well and again the same problem with yiisoft/yii2 2.0.9 requires bower-asset/jquery 2.2.#stable

Try to install composer global require "fxp/composer-asset-plugin: *" first. Also, make sure you have these added in your composer.json file:
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
Another solution is to attempt to self-update:
composer self-update --rollback
If these solutions did not work, you can try to use this sequence of commands:
rm -rf ~/.composer/vendor
rm ~/.composer/composer.lock
cd ~/.composer
composer clear-cache
composer self-update
composer global require "fxp/composer-asset-plugin:~1.1.3"
composer install
Source 1 | Source 2 | Source 3 | Source 4

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 latest stable version of Yii in a directory named basic. You can choose a different directory name if you want.

Related

How to Install CakePHP Console?

I have a CakePHP 3.8 project hosted on github: https://github.com/paultrimor/pecunia
I can successfully clone the project, run composer install & configure app.php to have the application run.
However; the installation does not create a /bin directory, meaning that I cannot use the Console/Shell.
I am looking to install the Console on an existing CakePHP project
I receive the following message when I win composer install and `composer create-project --prefer-source``
> App\Console\Installer::postInstall
Set Folder Permissions ? (Default to Y) [Y,n]? n
Updated Security.salt value in config/app.php
> App\Console\Installer::postInstall
Set Folder Permissions ? (Default to Y) [Y,n]? n
No Security.salt placeholder to replace.
The first command replaces the "SALT" string to an actual hash in app.php; But, the second command tries to do the same thing, which it cannot.
Any pointers are appreciated. Thanks.
I think you already solved it looking at your repo, but the bin/ folder should be part of your repository. It will not be created with a composer install or composer update command.
If you create a new project using composer create-project cakephp/app --prefer-dist the bin/ executables will be placed. If you don't explicitly ignore it in .gitignore it will be available to all developers.
Step 1 : check PHP Version
php -v
Step 2: Install Composer
step 3: create a new CakePHP application using composer.
composer create-project --prefer-dist cakephp/app projectname
while installing it asking permission for folder just give yes
Set Folder Permissions ? (Default to Y) [Y,n]? Y
it will work.

Yii2 | requires bower-asset/jquery

I'm trying to install Yii2 via composer:
composer global require "fxp/composer-asset-plugin:~1.1.1"
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
~/.composer/composer.json
{
"require": {
"fxp/composer-asset-plugin": "~1.1.1"
}
}
result:
Problem 1
- yiisoft/yii2 2.0.x-dev requires bower-asset/jquery 2.1.*#stable | 1.11.*#stable -> no matching package found.
- yiisoft/yii2 dev-master requires bower-asset/jquery 2.1.*#stable | 1.11.*#stable -> no matching package found.
- yiisoft/yii2 2.0.6 requires bower-asset/jquery 2.1.*#stable | 1.11.*#stable -> no matching package found.
- yiisoft/yii2 2.0.5 requires bower-asset/jquery 2.1.*#stable | 1.11.*#stable -> no matching package found.
- Installation request for yiisoft/yii2 >=2.0.5 -> satisfiable by yiisoft/yii2[2.0.5, 2.0.6, dev-master, 2.0.x-dev].
What do I do wrong?
rm -rf ~/.composer/vendor
rm ~/.composer/composer.lock
cd ~/.composer
composer clear-cache
composer self-update
composer global require "fxp/composer-asset-plugin:^1.1.3"
composer install
Then go to your work directory and run:
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
You can try the newer version:
composer global require "fxp/composer-asset-plugin:^1.2.0"
then:
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
Non-install Bower-Asset way:
You can download Yii2 by Install from an Archive File. By this way you won't need to handle Bower issue.
Further, if you need to update composer without handling Bower, you can require yidas/yii2-composer-bower-skip before yiisoft/yii2 in composer.json file:
"require": {
"php": ">=5.4.0",
"yidas/yii2-composer-bower-skip": "~2.0.0",
"yiisoft/yii2": "~2.0.5",
"yiisoft/yii2-bootstrap": "~2.0.0"
}
Instead, if you want to create yii2 project without bower-asset issue:
yidas/yii2-app-basic:
composer create-project yidas/yii2-app-basic
yidas/yii2-app-advanced:
composer create-project yidas/yii2-app-advanced
From Yii 2.0.13, it used Asset-Packagist solution instead of fxp/composer-asset-plugin
This problem could be also resolved via
composer require yidas/yii2-bower-asset
More details about this package: https://packagist.org/packages/yidas/yii2-bower-asset
https://getcomposer.org/Composer-Setup.exe
download and install. After installing run this command line in your project folder composer update
Solved. I needed to install the Composer Asset Plugin first:
php composer.phar global require "fxp/composer-asset-plugin:1.0.0"
First change the .composer permissions
sudo chown -R $USER .composer/
Then
composer global require "fxp/composer-asset-plugin:^1.2.0"

My composer.json does not install new dependencies using composer update command

I am installing external dependencies using composer update command. The following is the section of the composer.json file in c:\xampp\htdocs\myproject\vendor\laravel\framework\ directory.
"require": {
"laravelcollective/html": "~5.0",
"matriphe/imageupload": "5.1.*"
"illuminate/html": "5.0.*#dev"
},
I am getting the following results after running the composer update command:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
I have also tried to create another require array in the composer.json and added the packages I want to install with no success.
The composer update command could not install any unstalled dependency using the composer update command. Even composer self-update did not solve the problem.
Kindly assist me, I have been stuck here for some days now trying all I would do but without success.
I am changing the composer.json under the following directory: c:\xampp\htdocs\myproject\vendor\laravel\framework\ Is this ok?
Don't change any files inside the vendor directory, they are managed by Composer. To install further packages use the composer.json in your project's directory.
And use composer install to install new packages as composer update will update already installed packages to newer versions (if available) too.
composer self-update just updates Composer itself.
You missed column after "matriphe/imageupload": "5.1.*", try to change it:
"require": {
"laravelcollective/html": "~5.0",
"matriphe/imageupload": "5.1.*",
"illuminate/html": "5.0.*#dev"
}

Update composer.phar on Openshift

I have an application written in PHP using Fuelphp 1.6.3 and want to deploy it on Openshift
As the framework required composer, when I access my app at http://audit-manhthang.rhcloud.com/public/, it showed the error
Composer is not installed. Please run "php composer.phar update" in
the root to install Composer
I have Google it and found an article here: https://www.openshift.com/content/support-for-git-clone-on-the-server-aka-support-php-composerphar
I've tried to follow the instruction, create the file name deploy in .openshift/action_hooks folder and added following:
unset GIT_DIR
cd $OPENSHIFT_REPO_DIR/libs
wget -qN http://getcomposer.org/composer.phar
php composer.phar install
But it doesn't work. I have tried to revise install by update
unset GIT_DIR
cd $OPENSHIFT_REPO_DIR/libs
wget -qN http://getcomposer.org/composer.phar
php composer.phar update
But nothing change.
I use PHP 5.3 Cartridge on Openshift
When I did composer update
cd app-root/runtime/repo/php
/usr/bin/php composer.phar update
I received error like this
[RuntimeException]
/var/lib/openshift/52d3b7bd500446f4300001a5/.composer/cache/vcs does not exist and could not be created.
Composer is using $HOME variable to find root path. So to fix that I did.
export HOME=/var/lib/openshift/52d3b7bd500446f4300001a5/app-root/runtime/repo/php
and then
/usr/bin/php composer.phar update
worked.
After update was done I reverted $HOME
export HOME=/var/lib/openshift/52d3b7bd500446f4300001a5
Looks like there have been some changes how openshift works now. I know that this is quite ugly workaround. If I will find something better, I will update this answer. Still, hope this will help someone.
EDIT
Got it! :)
Create new file under .openshift directory:
.openshift/action_hooks/deploy
and mark it as executable.
#!/bin/bash
# Run composer install
cd app-root/runtime/repo/php
export HOME_ORIGIN=$HOME
export HOME=$HOME/app-root/runtime/repo/php
/usr/bin/php composer.phar install
export HOME=$HOME_ORIGIN
After that on every push composer will be updated to current composer.lock place. Perfect! :)
Also make sure vendor/ path is empty. Better add to .gitignore so it not messed up by your local setup.
Here is a slightly better solution than the others mentioned:
http://stanlemon.net/2013/03/22/composer-on-openshift/
The deploy script mentioned in the blog post:
a. downloads composer if not present and stores it in the data directory so that it persists
across git pushes
b. enables composer to use cached versions of packages in the .composer dir stored in the persistent data directory, thus decreasing the time required when doing frequent pushes
There was a small issue with the script - that the php version it was referring to was being complained as being too old by composer
remote: #!/usr/bin/env php
remote: Some settings on your machine may cause stability issues with Composer.
remote: If you encounter issues, try to change the following:
remote:
remote: Your PHP (5.3.3) is quite old, upgrading to PHP 5.3.4 or higher is recommended.
remote: Composer works with 5.3.2+ for most people, but there might be edge case issues.
So I changed the paths to use the latest present on the system
[domain.rhcloud.com action_hooks]\> php --version
PHP 5.4.16 (cli) (built: Dec 6 2013 01:17:01)
[domain.rhcloud.com 5316aa83e0b8cdb61b00023a]\> which php
/opt/rh/php54/root/usr/bin/php
The script in my .openshift/action_hooks/deploy is
#!/bin/bash
# Run composer install
cd app-root/runtime/repo/
export COMPOSER_HOME="$OPENSHIFT_DATA_DIR/.composer"
if [ ! -f "$OPENSHIFT_DATA_DIR/composer.phar" ]; then
curl -s https://getcomposer.org/installer | /opt/rh/php54/root/usr/bin/php -- --install-dir=$OPENSHIFT_DATA_DIR
else
/opt/rh/php54/root/usr/bin/php $OPENSHIFT_DATA_DIR/composer.phar self-update
fi
( unset GIT_DIR ; cd $OPENSHIFT_REPO_DIR ; /opt/rh/php54/root/usr/bin/php $OPENSHIFT_DATA_DIR/composer.phar install )
As the blog post suggests - create an empty hot_deploy file in the markers subdirectory to further speed things up by saying that the servers should not be restarted during a push -
touch .openshift/markers/hot_deploy
git add .openshift/markers/hot_deploy
git add .openshift/action_hooks/deploy
git commit -m "Speeding up composer installs across pushes"
git push origin master
And watch your git pushes be fast even when using composer.
I figure it out. With openshift, I can access via SSH and go to app-root(or something like that)/repo/php and then type /usr/bin/php composer.phar update. That's it.
For reference, OpenShift comes with built-in support for Composer. Adding the use_composer marker file, simply an empty file named use_composer, in your OpenShift project's .openshift/markers directory will automatically enable Composer install/update on deployment.
More specifically, each time you git push to your OpenShift git repo...
When in 'production' mode (default):
echo -n "Checking composer.json for Composer dependency... "
if [ -f ${OPENSHIFT_REPO_DIR}composer.json ]; then
echo
composer install --no-interaction --no-ansi --no-scripts --optimize-autoloader --working-dir=${OPENSHIFT_REPO_DIR} || \
echo -e "\nSkipping Composer errors..\n\n Please, fix the errors either locally or in development mode.\n"
if [ ! -f ${OPENSHIFT_REPO_DIR}composer.lock ]; then
echo -e $composer_lock_msg
fi
else
echo "File not found."
fi
When in 'development' mode:
if [ -f ${OPENSHIFT_REPO_DIR}composer.lock ]; then
echo "Ignoring composer.lock file (development mode)"
fi
echo -n "Checking composer.json for Composer dependency... "
if [ -f ${OPENSHIFT_REPO_DIR}composer.json ]; then
echo
composer update --no-interaction --no-ansi --no-scripts --optimize-autoloader --working-dir=${OPENSHIFT_REPO_DIR}
echo -e $composer_lock_msg
else
echo "File not found."
fi
Check out the code beginning at line #142 of the OpenShift PHP Cartridge.
Check out the Developer Portal article on enabling PHP 'development' mode for more details.
Check out the Laravel 5 QuickStart for example-use or for an easy way to get started.
I do not have enough points to comment on wormhit's answer, so I will append it here:
The zend/php-*/etc/php.ini file needed an update for OpenShift to work with the latest version of composer.phar as described here:
extension=phar.so
extension=ctype.so
Adding these extensions to it fixes PHP's complaints about composer.phar
The next fix required using relative pathing:
php composer.phar install
INSTEAD of absolute pathing:
/usr/bin/php composer.phar install
to allow the extensions to load.

Automatically install build dependencies prior to building an RPM package

I am trying to build a .rpm package. I have just followed the steps to do that. Till now all steps were gone fine but now i just stuck with this step. I just ran the following command and got this error:
rpmbuild -ba asterisk.spec
error: Failed build dependencies:
gtk2-devel is needed by asterisk-1.8.12.2-1.fc15.x86_64
libsrtp-devel is needed by asterisk-1.8.12.2-1.fc15.x86_64
[... more ...]
freetds-devel is needed by asterisk-1.8.12.2-1.fc15.x86_64
uw-imap-devel is needed by asterisk-1.8.12.2-1.fc15.x86_64
I am using fedora-15. How to resolve this error?
How I do install all depencencies during installation of src.rpm package. Is it possible?
You can use the yum-builddep command from the yum-utils package to install all the build dependencies for a package.
The arguments can either be paths to spec files, paths to source RPMs or the names of packages which exist as source RPMs in a configured repository, for example:
yum-builddep my-package.spec
or
yum-builddep my-package.src.rpm
The same thing can be achieved on newer versions of Fedora that use dnf as their package manager by making sure that dnf-plugins-core is installed and then doing:
dnf builddep my-package.spec
or
dnf builddep my-package.src.rpm
yum-builddep doesn't seem to work if the mirror you use doesn't serve source RPMs. This may not handle all cases, but it usually works for me:
sudo yum install -y $(<rpmbuild> | fgrep 'is needed by' | awk '{print $1}')
where <rpmbuild> is your rpmbuild command (e.g., rpmbuild -ba foo.spec).
On PHP building - especially phpbrew I used dnf builddep php, it worked.