symfony/skeleton and symfony/website-skeleton - php

At https://symfony.com/doc/current/setup.html you are instructed to run:
composer create-project symfony/website-skeleton my-project
whereas at http://symfony.com/doc/current/quick_tour/the_big_picture.html you are instructed to run:
composer create-project symfony/skeleton quick_tour
I have just done both. Using symfony/website-skeleton I got an error message in the browser: No route found for "GET /"
With symfony/skeleton I did get a Welcome to Symfony 4.0.4 page.
What are the differences between the two and why would you use one rather than the other?

The new symfony edition (Symfony 4) is "bundle less".
Symfony core team decided to not provide the Symfony Standard Edition for Symfony 4.0 that means when you run composer create-project symfony/skeleton you download the minimum package to start an application and you have to download the over packages needed and you need to explicitly add all the dependencies you want to depend on (twig, routing...) look here for other package .
But it could be difficult for new comers and the Symfony core team dediced to provide an edition with the minimum common Symfony features.
You get it with composer create-project symfony/website-skeleton.
You have more explanation here

Came here as a result of a similar search, but was more interested in what's under the hood.
Not to take away from the accepted answer, but for those who, like me, were after something more detailed, you can look at the package details in packagist and reviewing the dependencies noted in the requires and requires dev sub-sections:
https://packagist.org/packages/symfony/website-skeleton
Includes: framework, framework extra, console, asset, security, validator twig, doctrine, http client, serialiser, yaml, dotenv, flex, form and validator packages among others.
https://packagist.org/packages/symfony/skeleton
Includes: console, dotenv, flex, platform and yaml only.
Seems like a no brainer, but if you came here looking for it, it's there.

Related

What exactly is the difference between project and library types in composer?

I have a hard time figuring this out; I am also puzzled of the connection - if any - with the create-project command.
As far as I can tell, the only difference between install and create-project is the execution of post-root-package-install and post-create-project-cmd hooks...
Can someone shed some more light on this?
My goal is to set up a composer infrastructure where I run create-project and this sets up a project skeleton (creates and sets directory permissions, creates default configuration files, creates blank data stores)
What exactly is the difference between project and library types in composer?
Practically, there is none. It doesn't affect how composer gets executed. You can use both install and create-project with both types of package types.
This metadata is meant to inform plugins, IDE, or even packagist.org when parsing composer.json, but on a vainilla installation, there is no practical difference in using one or the other.
(Docs on package types)
As far as I can tell, the only difference between install and create-project is the execution of post-root-package-install and post-create-project-cmd hooks.
The docs are your friends:
You can use Composer to create new projects from an existing package. This is the equivalent of doing a git clone/svn checkout followed by a composer install of the vendors.
Any time you do create-project, install is executed as well. Which means that the install hooks are executed as well.
First it clones the whole package via the appropriate CVS (git, usually), and then immediately executes composer install. By default, it removes CVS information (e.g. the .git directory), unless one uses the --keep-vcs option.
create-project is useful to bootstrap applications, so the app's directory is setup beyond what downloading composer`s dependencies would do. You can create a skeleton directory structure, etc.
Usually one would have a package proper (that could be required into an application), and a "application-skeleton" package, that would include the directory structure and would depend on the original package.
I'm posting a more succint answer to my questions, based on experimentation:
What is the difference between project and library types?
Absolutely none as far as composer is concerned. Some plugins might implement logic to treat the two package types differently though.
How does that relate to require, install, create-project commands?
In no way whatsoever. The project in package type has nothing to do with project in create-project.
How does create-project work?
Let's say we are talking about a single <package>. We have 2 workflows:
composer init <project_path> && composer require <package>
composer create-project <package> <project_path>
The first workflow will create a blank root package and add <package> as a requirement to it.
The second workflow will "clone" <package> into <project_path> as the root package.
NB: If you are working with local path type repos for development, create-project will actually create <project_path> as a symlink to <package>'s source dir. This is the default behavior of path repos, and probably a miss for composer in the need to treat create-project differently. This can create a heap of confusion (as you might be inadvertently changing and adding to <package>s sources while thinking you are just editing project_path). So for local development and testing, you are better off with cp -A rather than composer create-project.

How to create composer package that can create skeleton files via composer create-project

I am thinking to create a project skeleton in the following format via a composer package that I am going to create.
/app
/config
/web
/vendors
Just wondering about this command
composer create-project vendor/name path
--repository-url=http://repo.yourcomposerrepo.com
What do I need to put in the composer.json in order to create the file structure I want? Is it done through the shell script or it just copied the files from the repositories?
For symfony it will create the files and folders automatically through composer create-project. Just wondering how do I achieve the similar thing for this case. When I looked at their repo it only contains one composer.json at https://github.com/symfony/skeleton
composer create-project symfony/skeleton blog
Thank you.
composer create-project will create a new directory with all the files that are part of that package and then it will run the installation for all the dependencies that are listed in that package's composer.json file.
If you want to have a better example to understand that, you can use the old way that we used to bootstrap Symfony applications (when not using the Symfony installer). Then applications were based on the Symfony Standard Edition which you can find on GitHub. Just run composer create-project symfony/framework-standard-edition and compare the result with the repository.
Using symfony/skeleton as the base package is a bit special. This package depends on Symfony Flex which is a Composer plugin that automatically applies so called recipes (see https://flex.symfony.com/) which will lead to newly created files when a package is installed (and clean them up on removal). But, this behaviour is special for Flex and thus nowadays Symfony 4 based application and not a good example for what composer create-project does by default.

Why does Composer Install a Different Package?

I've been working with the Magento Firegento custom Composer installer, and I ran into this odd bit of Composer behavior I don't understand.
Consider the following dead simple composer.json file
{
"require": {
"magento-hackathon/magento-composer-installer": "*"
}
}
If I run compser.phar install with this composer.json file, I get the following.
$ composer.phar install --no-dev
Loading composer repositories with package information
Installing dependencies
- Installing aoepeople/composer-installers (v0.0.1)
Loading from cache
Writing lock file
Generating autoload files
From my mostly lay-person's understanding composer.phar, I've said
Hey, composer, please install the magento-hackathon/magento-composer-installer package from packagist.org
And composer has said back to me
Sir, yes sir! Here's the aoepeople/composer-installers package
I don't understand why composer installed aoepeople/composer-installers, when I asked for magento-hackathon/magento-composer-installer.
To be clear: I understand the reason magento-hackathon/magento-composer-installer wasn't installed is this is a package that lives in a different composer repository. My original mistake was not including this repository in my composer.json file.
However, it doesn't make sense to me that composer would install a different package than the one I asked for. When I search packagist there's no magento-hackathon/magento-composer-installer extension.
Why does packagist install a different extension? What's happening behind the scenes to make magento-hackathon/magento-composer-installer resolve to aoepeople/composer-installers? How/where in the composer source could I debug this sort of thing myself in the future?
Vinai published a great writeup on Magento and Composer here.
Quoting from there
Composer will use packagist.org to look where to get the libraries. Because Magento modules aren’t listed there, you will have to add the packages.firegento.org repository to the configuration as follows [...]
So you will need the repository
"repositories":[
{
"type":"composer",
"url":"http://packages.firegento.com"
}
],
to get the magento composer installer.
And yes composer offers replacements. On the packaging entry for aoepeople/composer-installers you will notice the replaces section:
And since magento-hackathon/magento-composer-installer is not available on packagist composer will deliver you aoepeople/composer-installers.
OK, so that's a weird behavior :) I'm the author of the aoepeople/composer-installers package and the idea behind this is that this package provides an alternative (very basic and simplified implementation of the composer package-type magento-module - and adds another type magento-source. I only want the installer to put the package in the right place - keeping it simple. That's why I decided to come up with an alternative package.
The reason why the aoepeople/composer-installer replaces the magento-hackathon/magento-composer-installer is because many Magento modules already come with a composer.json that requires the magento-hackathon/magento-composer-installer. In order to be able to seamlessly use the simpler installer that one is "pretending" to be the hackathon-installer. But unless you actively require aoepeople/composer-installers in your project's composer.json you should continue using the original installer as no Magento module's composer.json out there (not even ours) is directly referring to aoepeople/composer-installers.
The fact that packagist tries to be "smart" and returns a package that replaces a package that's not registered is new to me and - to be honest - very disturbing. While this might be intended behavior I share the opinion that this could easily be abused. I start liking Alan's idea to bypass packagist completely using "packagist":"disabled". Especially in the case of Magento modules this seems to happen easily because most of the Magento modules are unknown to packagist while being registered at packages.firegento.com only.
A simple quickfix/workaround to this specific situation could be to register magento-hackathon/magento-composer-installer on packagist.org.
The Packagist package at https://packagist.org/packages/aoepeople/composer-installers has metadata saying that it replaces the magento-hackathon/magento-composer-installer package. Packagist would then install this as it's the package that replaces what you asked for.
Docs here: https://getcomposer.org/doc/04-schema.md#replace

Should I download Laravel for every project?

I created a project with Laravel and downloaded from git via this command:
git clone -b develop git://github.com/laravel/laravel.git
The file size was about 21MB,
I want to know should I download Laravel for every project with this command?
What you have done is cloned the framework itself, which you should only do if you're going to fork and develop the Laravel core.
What you should do instead is use Composer to install your Laravel projects. You'll also be using Composer for other dependency-related actions in said projects (including autoload). This is the proper way of installing a fresh Laravel framework for developing a website:
composer create-project laravel/laravel --prefer-dist
http://laravel.com/docs/installation
Then, any future Laravel projects you create will be loaded from your Composer cache without needing to re-download.
The Composer package also sets up all your vendor-related .gitignore information and includes several other really useful management features. This is important, because you only want to keep your application-specific code under git version control, not the framework itself or any other dependencies. (Otherwise, your diffs and commits will get polluted with the dependencies' development changes.)
Once you've created a repository for your project, and installed Laravel with Composer, and created your first few commits (with some migrations, models, and controllers, for instance), cloning your project usually works something like this:
cd /clone-here
git clone /myproject # Location of current project
# /clone-here now has only the application-specific files from /myproject. It is
# still missing the framework itself and other dependencies.
composer install # Composer now looks at the dependencies in
# /clone-here/composer.json and installs them into /clone-here/vendor
# including the Laravel framework.
# Now the framework and other dependencies are good to go.
php artisan migrate # Laravel makes all your DB schemas from your migrations
php artisan db:seed # Seed your lovely new DB tables
It's really elegant and fun once you get used to it.
Edit:
See Sheikh's answer to save some time in the Composer install process!
Already Leng gave a nice answer.
Installing Laravel since version-4.1* via Laravel Installer is faster than composer
First, download the Laravel installer PHAR archive. For convenience,
rename the file to laravel and move it to /usr/local/bin. Once
installed, the simple laravel new command will create a fresh Laravel
installation in the directory you specify. For instance, laravel new
blog would create a directory named blog containing a fresh Laravel
installation with all dependencies installed. This method of
installation is much faster than installing via Composer.

Laravel 4 logic?

I recently downloaded a version of Laravel 4 and it was only 40kb. Laravel 3.2 was about 3.5mb, my questions are:
How can I use Laravel 4 completely offline?
I found out, Laravel 4 core codes was missing, Does it work cloud base or something like it!?
Which version do you recommend to use? Laravel 3.2 or Laravel 4? ( mostly for local developing )
thanks.
How did you installed Laravel? Using composer is as simple as:
composer create-project laravel/laravel your-project-name --prefer-dist
I use Laravel 4 for local development, and it works like a charm!
That's mainly because Laravel 4 uses composer to handle dependencies. What you downloaded wasn't exactly Laravel, but rather the structure for it. It's a preset project, with all default Laravel dependencies, so that all you have to do is run a command and download it all.
To use Laravel 4, you'll need to install composer. After you're done, open your command line, go to the folder where you saved the Laravel files you downloaded and, inside it, type: php composer install. This will download all the dependencies needed for the project; that means Laravel files and all of its own dependencies. It may take a while to install, and may seem to be stuck at Installing dependencies (including require-dev) for quite a long time, since there are lots of dependencies to be fetched, but that's normal. After it's done, you should see something like this:
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing doctrine/lexer (dev-master bc0e1f0)
Downloading: 100%
...
- Installing laravel/framework (4.0.x-dev 733492c)
Downloading: 100%
...
Writing lock file
Generating autoload files
Generating optimized class loader
Now all you have to do is point the root of your webserver to the /public folder and start programming. If you ever feel you want to update your dependencies, simply run composer update.
Note: Remember to enable PHP's openssl extension, so composer can download the projects from github, and Apache's mod_rewrite, so Laravel pretty URLs work. If you're using Apache, that is.
Note²: Whenever you create a new command, controller, model, migration or seed, you'll have to type composer dump-autoload on your console, so composer knows how to autoload it.

Categories