Composer install create folders in second time only - laravel

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

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.

Provider Class not found in In ProviderRepository.php line 208

I have create a simple Laravel Package and pushed it on Github
https://github.com/akshaykhale1992/model-notes
and Published the Package on Packagist
https://packagist.org/packages/akshaykhale1992/model-note
I tried to install it in my laravel application, it pulled the package from Github but the package installation was not successful.
Below is the Error that is returned by composer command
root#root.com:~/$ composer require akshaykhale1992/model-note
Using version dev-master for akshaykhale1992/model-note
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing akshaykhale1992/model-note (dev-master 5543914): Cloning 554391487e from cache
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover
In ProviderRepository.php line 208:
Class 'AkshayKhale1992\ModelNote\ModelNoteProvider' not found
Script #php artisan package:discover handling the post-autoload-dump event returned with error code 1
Thanks in advance.
Terminal Screenshot
In order for composer to properly generate the autoload file for your package (as well as all packages) it needs to know where to find the namespaces and files that are referenced. This is done via the autoload entry in composer.json
In your case, since you are already following the PSR-4 standard you need something like:
"autoload": {
"psr-4": {
"AkshayKhale1992\\ModelNote\\": "src/"
}
}

Script php artisan optimize handling the post-install-cmd event returned with error code 255

After clone the git repo, install composer and Laravel , this error will come out. Anyone can solve this error?
When I run laravel new, I get this error:
Crafting application...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> php -r "file_exists('.env') || copy('.env.example', '.env');"
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
Script php artisan optimize handling the post-install-cmd event returned with error code 255
Application ready! Build something amazing.
Which repo you cloned? if you want create a new laravel project, just try run laravel new projectName,
check the doc here

composer.json file property name is required

I am using composer for the first time so if I shouldn't be posting here I am very sorry.
I am following a youtube tutorial on the paypal api I have installed composer and created the json file the same as the example. composer.json is saved in the root folder for the website. the structure is below. composer diagnose composer.json: fail and property name is required.
{
"require": {
"paypal/rest-api-php": "1.5.1"
}
}
looks like your composer had much fresher version, check composer --version !
need to update composer.json with:
{
"name": "some/name",
"description": "Some description will be useful too!",
"require": {
"paypal/rest-api-php": "1.5.1"
}
}
or install some old version, by exec 3lines
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer --version=1.0.1
php -r "unlink('composer-setup.php');"
The best way to start a project using Composer:
composer init
This will ask you some questions, some of them with sensible defaults that you can simply accept - others (like the name of your project) cannot be guessed.
The best way to install a package after that
composer require package/name
Optionally for development packages:
composer require --dev package/name
The composer command used here assumes you have downloaded "composer.phar" and renamed or symlinked it in a way that it can be called just by typing composer. Otherwise, replace that command with the one that works for you, like php composer.phar or composer.phar.

Laravel dependencies error Composer install error in Mac OSX

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!

Resources