Create folder when installing composer package - composer-php

Is it possible for a composer package to create a folder (or folders) in the root directory of the project?
For example:
/ansible
/application
/public
/composer.json
/composer.lock
I run composer install to install my package (framework).
Can this framework create the folders /logs in my root directory?

You might want to have a look at https://getcomposer.org/doc/articles/scripts.md and check the post-install-cmd event name and supply your own script to create your needed directories.

Related

Calling class from vendor

EDIT Autoload
require __DIR__ . '/../../../vendor/autoload.php';
I am calling it this way:
$generatorSVG = new \Picqer\Barcode\BarcodeGeneratorSVG();
The error:
Message: Class 'Picqer\Barcode\BarcodeGeneratorSVG' not found
The class exist. I am not installing it via composer but copying it in the vendor folder, because I dont have composer and the server and dont have permissions to install it.
Using PHPStorm and by ctrl+click on the class leads me to it. I am wrong with the proper calling it in CI ?
Manually copying files in the vendor directory is not enough, because Composer generates a bunch of lookup files (vendor/composer/autoload_*.php) to be able to figure out where the files are located that you want to load via Composer's autoloader.
Either, you should composer require the package you want to install or require all your source files manually in your bootstrap.php or index.php.
If this is a custom package you built, be aware that Composer can also pull it directly from a Git instance, local directory, or zip file. There's no need to create a public package on Packagist or self-host it with Satis. Check the Composer docs on how to configure repositories to find out more.

Is npm install affecting Laravel project?

I am working on the Laravel project, and intend to use Vue.js as its client-side scripting. When I searched the internet, I found that I had to use the npm install command. My question is if I run the order, will it affect the project I'm working on?
For example, in the directory structure or variable section?
It will change only package.json and /node_modules folder (it will download vue.js last version package into this folder) in your root directory. But it won't affect your existing codebase until you don't use them via importing or accessing it. It is like installing a package with composer, but not using it. The downloaded package will stay in /vendor folder and package name in composer.json, composer.lock

When a package is removed all package files should be removed?

To remove a package using the command "composer remove vendor/vendor" it works, the command dont shows any error. However the package files (classes, etc) are not removed from the folder of the project. Its necessary to remove manually the package fiels that are not removed with the remove command?
Just if you want to remove them from your disk.
If you are running in developer mode, i think that has no problem to let them there, because when you go to deploy your project a new fresh installation script will run with the information of your composer.json, if in your composer.json file don't have any entry with the 'vendor/package' which you want to remove, it will not be installed.
Commonly composer removes any packages that aren't in your composer.json package list fom the vendor folder.

What files are need to upload after composer required <package>?

So my hosting company not support composer. and reuploading all Laravel framework php files are too much take time just for one composer package. what are files need to be uploaded to hosting after composer required?
all i know is "package" folder in vendor folder, composer.json, and "config" file in config folder. is there any other files and folder?
You must upload vendor/composer and vendor/autoload.php too..
I hope this works
The file that you forget: Facades, ServiceProvider
the easiest way is reupload all vendor directory. or track all vendor directory using git, so you can archive the different after update composer and upload it

Node.js modules

I want to install this module: node-poormansmysql.
My nodejs application is installed in C:\Program Files\NodeJS\.
I have here the folder - node_modules.
Here I added a folder - node-poormansmysql. In this folder I copied the content from github.
I still have the error - Can not find module - node-poormansmysql
Where am I going wrong?
Try to copy to C:\Users\{username}\node_modules
Or just type in cmd "C:\Program Files\NodeJS\npm.cmd" install node-poormansmysql
The problem is that node will look for an index.js in the folder (or a package.json) and this library have not been packaged as a module.
So what you need to do is re-name node-poormansmysql.js to index.js
Also make sure you get all the dependencies.

Resources