I have a package which is an extension to some wiki software that has several dependencies and can be installed into this wiki software using Composer.
I'm using Jenkins for CI and when a commit gets submitted to my code review system, Jenkins gets the corresponding modified version of the extension. Now I'd like to install the dependencies of this extension in my wiki software. As in, only the dependencies, without the actual package, as I already have this.
Is that possible? Is there another easy way to get my CI setup to use Composer?
Whenever you check out your wiki extension from the repository, you should run composer install right after it.
If you have the necessary toolset installed, you can download these dependencies anywhere, whenever you locate the main composer.json file. Do not confuse that file with all those probably included in the referenced software - you'd find a lot of composer.json files in the generated vendor folder, because they are also used to identify usable software libraries, not only as a list of dependencies.
Related
I am reading/learning about Composer, the application-level package manager for PHP.
In this blog post written by lead dev Jordi Boggiano, he writes:
Composer on the other hand forces you to declare your project
dependencies in a one-stop location (composer.json at the root). You
just checkout the code, install dependencies, and they will sit in the
project directory, not disturbing anything else on the machine.
Another related feature is the composer.lock file that is generated
when you install or update dependencies. It stores the exact version
of every dependency that was used. If you commit it, anyone checking
out the project will be able to install exactly the same versions as
you did when you last updated that file, avoiding issues because of
minor incompatibilities or regressions in different versions of a
dependency.
If I understand Composer properly, when we're talking about packages downloaded/installed by Composer, we are talking about PHP code packages, ie, programming code written in PHP, and not system-level packages, eg, extensions to the PHP runtime installed on the server. So once these PHP code packages have been downloaded and added to a PHP project, I would have thought those packages become part of the PHP application source code, eg to be checked in to whichever version control system is being used for the project. If another developer comes along and checks out the code, why would they need to then "install the packages", as is stated in the blog post? Wouldn't they get a copy of all code packages when they check out the code from source control? This line in the blog post is confusing me, and making me think I don't understand Composer.
Any clarity on this would be greatly appreciated. Thanks.
The dependencies themselves should not be commited to source control. The composer.json and composer.lock files, on the other hand, should. There's various reasons for this, amongst them:
Every time you update the dependency you would have to commit the changes. That kind of tightly couples your code to the dependency, when it should be exactly the other way around.
The packages themselves are already in their own repository with their own history. Why repeat that in your project's history?
Those repositories can be huge, just muddling the waters around your project. Why carry around all that weight?
Instead, having each developer just run composer install (very important: not composer update) whenever they check out the project is much more efficient. Composer will install the dependencies from composer.lock, making sure everyone running the same commit is on the exact same page. The same goes for deploying.
You can read more about this here.
On the other hand, there might be situations where you have to commit your packages to get around a problem, like for example when you know you won't be able to run composer install on your production server (shared hosting)
Normally packages installed via composer don't get checked in to source control, only the code you write and the composer.json and composer.lock files.
This way the repository for your project does not get bloated with code you did not write and possibly don't really care that much about.
Yes its normal after cloning down your repository a developer will need to run the "composer install" command. The composer.lock file will ensure they get the same modules and versions of them you used when creating your project.
Not including the composer modules in your source control also allow you to easily update to the modules to get bug fixes and new features in new versions of them.
I'm currently using composer for managing my projects requirements. One of the packages I use have a bug, which is fixed in the dev branch of this package, so I used "dev-dev#dev".
The problem is, the composer.json file of the given package, also requires and dev package of another package, which I dont want to install (actually I can't because of other requirements..)
Is there a way to tell composer, to ignore the requirements of my dev package, or how could I sovle this without patching the extension on my own?
need a --ignore-platform-requirements or such flag that skips those requirements while loading packages
I'm wondering how I would be able to load PHP packages without using composer to do so.
I'm unable to use composer as I'm using shared hosting, which imposes limitations like being unable to install composer due to a heavily jailed shell.
While there are certain packages which allow for the loading of a package with require_once('package/Autoloader.php');, i.e. Braintree & Twig.
However, not all packages can be loaded like this, example being,
Pug-PHP, which only includes installation with composer.
Can anyone help me load composer packages without composer?
This is not possible due to Packages being a dependency of the composer management system. Replicate the ENV locally and use #MichalGallovic 's suggestion.
There is also the option of git clone every package and dependency from their respective source repos; but at that point you will hate yourself.
Is the option of using a host that are not as strict an option?
Visit https://php-download.com/ They have a number of packages ready to go that will no longer need Composer. It finds and creates all required folders and creates a zips it for download. Saves me hours of drama.
I downloaded Laravel from github and save it on c:/htdocs/laravel1
and I created a copy of my laravel with CMD (with composer) and I install this as laravel2 in c:/htdocs/laravel2 directory.
Laravel1:
c:/htdocs/laravel1
Laravel2:
c:/htdocs/laravel2
And I have access to both of them in localhost:8080/laravel1/public/ and
localhost:8080/laravel2/public/
My question is : Why should I install laravel by composer? There is no different between the installed laravel and downloaded laravel.
There are many, many valid reasons to use composer:
Composer creates optimized autoloaders if you want it to
Allows you to add thrird party dependencies easily (just add them to composer.json)
You can track the composer.lock file, and use composer install to ensure the exact same versions of the dependencies are being used throughout (on all environments, by everyone contribbuting) This is a must-have, if you're using automated builds!
Updating all dependencies, including Laravel, is a simple matter of composer update
Composer supports post-install and post-update scripts, to be executed after a composer install/update is run. This is quite commonly used to prompt the dev for configuration parameters. Downloading the code means you have to edit the config files by hand, and worse of all: track them in git or svn
... I'll probably add more reasons along the way, these are just a few off the top of my head
Update:
Just thought of some more reasons why using composer is a good idea:
Composer packages themselves can, and often do, define dependencies and requirements. Things like "php": ">=5.4.0", or "ext-curl": "*" will alert you to any missing PHP extensions or a version mismatch. These requirements can also trigger composer to fetch additional dependencies. Which brings me on to the next point:
Laravel itself has dependencies: Laravel uses components from Symfony2, for example. The easiest way to manage its own dependencies is to use composer, seeing as Symfony does, too. If you run composer update, the dependencies of Laravel will be checked, and updated where needed. Doing this manually is possible, but it's tedious, and really not worth the bother. Repetitive, dull jobs make people grumpy. Computers don't have this problem.
Composer is a dependancy manager similar to node's npm which allows quick and easy management of 3rd party libraries & packages on a per-project basis.
I recommend reading https://getcomposer.org/doc/00-intro.md to find out more about composer and explore https://packagist.org to find out the kind of things that are available through composer
I have tried to install both ZendPdf and TCPDF into ZF2 using Composer without success.
Software is installed and autoload files are written but nothing works, ZF can't see them.
Which files do I need to edit in order to manually install TCPDF library so that it autoloads?
I have found lots of similar questions in StackOverflow but not many working answers that don't involve Composer.
In fact, you don't install them without Composer. I think it is easier to make Composer work than to install them by hand.
In theory you could install them by hand. Just download both components in a version you like. Then look into their composer.json file if you need to download some more software these libs need. Download them as well. Have a look in their composer.json to download even more software.
After these downloads, unpack the packages, create a whole directory tree of files, and create the autoloading manually. Which means again you have to look at all the composer.json files for the definition of autoloading. You are lucky if you find PSR-0 or PSR-4 autoloading, and you have to manually scan EVERY file in the directory if you have classmap autoloading.
You then simply push all these definitions into your own autoloader and hope it works.
Done. That was easy... NOT!
I can help you get Composer to work, but I cannot help you NOT use Composer. Ask a new question describing your problem using Composer.
Please follow these instruction below to install Zend without composer. But I recommend to use composer for future consistency
Download latest stable copy of ZF2 from http://framework.zend.com/downloads/latest and unpack, we call it "ZF2"
Download latest stable copy of ZF2 skeleton app from https://github.com/zendframework/ZendSkeletonApplication/ and unpack, we call it ZF2Skeleton
Create folder like /vendor/ZF2
Now copy ZF2/* into /vendor/ZF2
Now you need to fix ZF2_PATH or $zf2Path variable at “/init_autoloader.php” file of root to point our “/vendor/ZF2” folder. Find "$zf2Path = false;" line into "/init_autoloader.php" file and replace it by "$zf2Path = 'vendor/ZF2/library';"
That's all. You may visit https://shkhan.wordpress.com/2014/04/26/install-zend-framework-2-into-windows-iis/ for more information about installing ZF2 without composer.