Laravel dependencies error Composer install error in Mac OSX - laravel-4

I have the following error when install laravel dependencies with composer
PHP Parse error: parse error in laravel/framework/src/Illuminate/Support/helpers.php on line 411.
I looked at the source code of
https://github.com/laravel/framework/blob/master/src/Illuminate/Support/helpers.php#L411
$results = [];
I believe the reason of this is the new array syntax of php.
It seems like the library has some incompatibilities.
Below is my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}

You say you're running OS X, but:
What is your PHP version?
How are you running your server (i.e. MAMP, plain Apache, Vagrant)?
Even without knowing the above, the line in question has the following:
$results = [];
Meaning it's creating an array with short syntax which is only supported by PHP 5.4+. You probably have an earlier version, hence the syntax error.
I'd say update PHP if you can, or use Laravel 4.1 if you can't.
Update:
If you have a compatible PHP already installed, it's probably just a matter of pointing Composer to the proper version. Just open a new Terminal window and type cd ~, then create a .bash_profile file by typing vim .bash_profile. Check the path of your XAMPP php folder (I haven't verified the path below, it's just a best-guess example), and add it to the new file:
export XAMPP_PHP=/Applications/XAMPP/xamppfiles/bin
export PATH="$XAMPP_PHP:$PATH"
Save it (esc > type :wq > enter), then reopen Terminal and try php -v and which php to see if Terminal is now using your XAMPP PHP. If not, check the path and try again!

Related

How to require node_modules from my own Laravel project packages

I'm setting up my own Laravel Package, and want to create dependancies to some node_modules. How can they be required in the composer.json of my package for this is not linked to the node_modules.
Used Git Bash to install to create my package in the packages/my/project/ folder and my composer.json looks like this:
{
"name": "my/project",
"description": "Description.",
"keywords": [
"front-end",
"framework"
],
...
"require": {
"php": ">=7.1.0"
},
I want te require from node_modules: #vue/component-compiler-utils
You can require them in package.json file in your root directory and then run a npm install. And then add them to your app.js or bootstrap.js file under resources/js and run a npm run production.

How to write an odd case version constraint for composer?

The constraint that I am interested in is
"require":{ "php": "..."
Is there a way to target php 7.1 for the project packages in composer.json even though I'm running 7.2 when I call composer update/install on the command line?
You can use platform configuration from Composer: https://getcomposer.org/doc/06-config.md#platform
Basically, your composer.json would look like this:
{
"require": {
...
},
"config": {
"platform": {
"php": "7.1"
}
}
}
This will make sure that you install only packages compatible with PHP 7.1, no matter which PHP version you use to actually install the packages.

Composer install create folders in second time only

I have a problème with composer install, if I launch the last command, it creates the vendor folder in my Laravel 5 project, and all its dependencies, but doesn't create folders what I want to some folders at the same time.
I added the following lines to my composer.json file:
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize",
"mkdir public/kit",
"mkdir public/files",
"mkdir public/sites"
],
The problem is, that if I launch the same command (composer install) a second time, It said:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
Illuminate\Foundation\ComposerScripts::postInstall
php artisan optimize
Generating optimized class loader
Compiling common classes
mkdir public/kit
mkdir public/files
mkdir public/sites
And It creates the folders what I need ...
Any help please?
Thanks alot
The "post-install-cmd" needs to be placed inside the "scripts" root entry:
"scripts": {
"post-install-cmd": [
"mkdir public/kit",
"..."
],
"post-update-cmd": [
"UPDATE ACTIONS",
"..."
],
}
you can install composer only one time.
after installation you can update composer.
commond :- composer update

composer create-project - command donot work

I have my project on github containing composer.json in the root directory.
This is how my composer.json code looks like:
{
"name": "vendor/projectname",
"description": "My first Composer project",
"authors": [
{
"name": "John Deo",
"email": "johndeo#demo.com"
}
],
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": "~5.3"
}
}
I had defined/submited my package on packagist.org.
Now when I try to get the project in my localhost using composer create-project - commands one of its work and another do not work.
1. composer create-project -s dev vendor/projectname >> WORKS
2. composer create-project vendor/projectname >> DO NOT WORK
Can someone please tell why the second command does not work.
What am I missing or doing wrong?
Please Help!
You're missing a stable version of vendor/projectname. In git, a tag (without flag) is a stable version and branches are dev versions. So you have to tag a release (e.g. git tag 1.0.0).

Composer test branch install

I have made a test branch to test some composer installations:
https://github.com/Sangoku/laravel4-idehelper-generator/tree/compabilityTest
Now I want to install via Composer this changed branch on my Laravel project, but I don't know how I could tell composer to pull my version of the code.
I don't know Composer enough to tell it which branch he should pull.
Edit your composer.json and:
require the package
"require": {
...
"jonphipps/idehelper": "dev-master"
},
And set the repository for it to be downloaded from
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Sangoku/laravel4-idehelper-generator.git"
}
],

Resources