Composer advantages [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
In our company we currently do not use composer, we just download and store all libs under git.
What arguments can be given to our customers and system administrators to convince them of the need to use composer?
Our request must be substantiated enough to make a decision.

With Composer you get the following advantages:
The dependencies required by the package you are pulling in are automatically taken care by Composer itself, leaving you free to focus on the programming instead of dependency management.
When the package you are using gets a new version, a simple composer update will do everything for you without ever needing to do any file management manually.
With Composer you get a centralized autoload.php file which also be optimized for production. It loads everything you need and all you need to do is include one file. The optimized version is super fast! Simply do composer dump-autoload -o.
You can use psr-4 namespaces to load a specific path on your application and have it be included in the autoloader file. Then you can simply use the namespace and it's available application wide!
Look at the following URL for a more detailed list of features: https://getcomposer.org/doc/01-basic-usage.md
There are a lot more things you can do with Composer and it's wonderful. I highly advise that you guys use it and stop wasting time on managing packages yourself.

Related

How to easily generate a minimal php project with phpunit and composer? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to solve a kata using PHP and test driven development. I would like to use a generator or template to base on a minimal composer project with phpunit.
The minimal project should contain:
the composer.json with phpunit as require-dev
the vendor folder
a sample tests folder with a test file and a source file
I wondered how other developers do that in PHP and found so far the following options:
use PHPStorm and create a new composer project based on laravel/laravel followed by php artisan key:generate as described here and here
use composer init as described in this post
use php-pds/skeleton followed by composer require phpunit/phpunit --dev as described here
What is typical way for a PHP developer to deal with the initial boilerplate in a small php project?
I can offer you my approach as a reference:
I have a skeleton in PHP with composer and PHPUnit with a class and its test already set up. When I want to challenge a new kata, I just create a new kata and duplicate the skeleton in it (https://docs.github.com/en/free-pro-team#latest/github/creating-cloning-and-archiving-repositories/duplicating-a-repository), then updates readme and class names to reflect the kata. Usually, I use master as the reference for the kata to start, and each attempt is a new branch from master.
Here is the link to my repo as a reference, you can use it as a template :)

What to include in software metric calculation on laravel project? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Laravel project contain a lot of files and folder.
When we are calculating the Software Metric, should we include them all?
I am using phpmetric but it ignored the vendor folder.
But when I use phpdepend , it included that folder.
Thanks.
It depends on what you're measuring, which is why there's no one answer and similar tools may, or may not, include the vendor folder.
If you're interested in the analyzing your own project, then you'll want to point these tools at files you'll be editing. In Laravel 5 that mostly means the app folder -- but you might want to include config and bootstrap, as user created code often finds its ways in those folders.
A reason you might point it at vendor is if you were concerned about the direction a particular code library you use is going, and wanted to measure it over time.
Hope that helps!
vendors (external code) is not important for you. When you measure your project, you should measure YOUR code only:
vendors are already tested / measured in their own repository
if you include external librairies, you don't measure your work
your should exclude generated files (cache...). They are not representative of your work
you should exclude test files : they do not obey the same quality rules
If you want to get information about a particular code library you use, you can check the Github repository of this library. There is a list of PhpMetrics representations of main PHP projects, you can also keep on eye on it.

Composer packages for functions. Bad form? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I just recently got into (learned how to) making composer packages, and want to distribute some functions I've made over the years.
I understand that you can autoload files containing just functions by using the files autoloader, but I was wondering what the "best practice limit" is for doing this.
Namely: Is it acceptable to distribute composer packages containing only functions? What about single functions?
I think it is very acceptable.
The composer documentation states:
It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
If your functions can be seen as a software package there is no reason why you should not publish them via. composer. There are countless composer-packages out there only consisting of a single class or even a single interface.
But you should try to group functions that belong together in one composer-package.

Git Subtrees vs Composer [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
This may be a pretty naive question, but I am trying to understand the difference in utility between Git's Subtree and Composer dependency management for PHP. I started using Git Subtrees after dumping Git Submodules. But now there is Composer (for PHP). As most of my projects are PHP based, I am thinking of dumping Subtrees in favor of Composer.
For example, I have multiple Wordpress sites. I would like to pull Wordpress itself and the plugins I want to use. I can achieve that with both Git Subtrees and Composer, right?
IF I don't have a use-case to commit/push code in a sub-folder upstream, but only wish to pull the latest/specific version into the sub-folder, do Subtree and Composer provide the same kind of utility?
In my use case, I feel that Composer trumps Git Subtree by being easier to use, easier to get another/newer version of a script in a sub-folder, without getting those pulled sub-folder files committed into Git repo.
Any thoughts on this understanding of mine? Is there a problem in this sort of strategy? Or both of them are totally different and don't have any similarities?
Lots of reasons favor Composer.
It actually manages dependencies of a whole project and vendor libraries themselves. So if you require a package it will get all required stuff or notify you about errors.
Managing versions is also trivial, as for every package you download you can specify version it should be updating to (so you can decide to only update minor releases of a package or go full-out with dev-master)
Composer provides some help with autoloading too. Making your project a little bit faster when run with -o
Having development only packages also allows you to manage production settings easier.
I find literally no reason for using submodules if vendor provides composer functionality.

What's the best way to modify/compile source code of open source projects? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Like PHP and ubuntu.
Is there a convenient way to see the modification alive?
Many open source projects are compiled with those three steps:
./configure
make
sudo make install
The first checks for dependencies and creates a makefile that matches your installation.
The second does the actual compilation and the third one installs it into /usr/bin or whereever it goes.
If you want to modify the code, I recommend you first do the above steps on the unmodified code, to make sure your tool chain actually works as expected.
Each project is different. Most projects have a "How to build" section in their documentation.
To keep up to date with changes in the code I would recommend joining the appropriate mailing list or whatever discussion mechanism the project uses.
You could also subscribe to the RSS feed of the source control or ticket/bug system used by the project.
For the two projects you mentioned have a look at the following sites:
PHP
Using PHP with SVN
Using SVN for PHP Development
PHP Bugs
Ubuntu
Ubuntu Development
Ubuntu Launchpad

Categories