Composer: Updating a Project Created with `create-project` - php

Does composer provide a way to update the package a project was created with? i.e., if I create a new laravel project with the following
composer create-project --prefer-dist laravel/laravel blog
Composer will grab the latest version of the laravel/laravel package, unarchive it into the blog folder, and then run composer install from the blog folder.
What I want/need to know is, does composer provide a way for me to update the laravel/laravel package that was downloaded to the blog folder? I know I could run composer update inside the blog folder myself, but this will only update things listed in the compser.json's require property — it will not update the unarchived laravel/laravel in blog (or will it?)

As far as I know it's not really possible.
Imagine that you create a new as example Laravel project.
The composer create-project creates the skeleton with all initial routes in your configuration etc.
From the very very first moment you are starting to change the default routes, removing the default controllers and changing the default views, your project would be out of sync. because meanwhile laravel changes the skeleton to newer versions with some new default routes etc or event changes directory structure.
It would be really hard to merge those changes over your existing application.
A better solution would be to follow the "Upgrade guides" (laravel: https://laravel.com/docs/5.4/upgrade) and then just commit those changes to your own project.

If you want to upgrade to a new laravel version, you can always follow the upgrade guide for your specific version:
Laravel 5.8 to 6.0
Laravel 5.7 to 5.8
Laravel 5.6 to 5.7
Laravel 5.5 to 5.6
If you are more than one version behind, you need to apply the previous upgrade guide. So if you are on 5.6 and want to upgrade to 5.8, you need to follow the guide for 5.6 to 5.7 and then from 5.7 to 5.8.
The guides are pretty helpful: they tell you which package must be updated to what version and inform you about deprecated methods which will be removed in the upcoming versions.
Another method which you can use to upgrade to new minor versions is to just look at the differences from one laravel release to the next. That way, you can see what exactly has changed and which files are new (configuration files for example which you can copy and paste into your project as the default composer create-project command would do).
As for the current version, you can see the commits since last release here: v5.8.30 to 5.8
Directly under the headline for a release, there is a small link labelled "36 commits to 5.8 since this release" which will take you to the link above, just for the latest version.

That's not the goal of composer, that just manage your packages.
You should see composer create-project just as a shortcut of git clone + composer install. If you need to deploy your application you've multiple options, from a simple git pull, to more advanced deployment tools like Capistrano. But composer isn't one of these tools.

I just needed to do this, and I couldn't find anything simpler than a git clone and a git pull (as #Federkun). Maybe an alternative would be to publish a phar file for the project and download that?
I can see db-ping does this. It's based on joomla/using phar. Here is the main file for building, inspired from joomla's file.

Related

Symfony difference between website-skeleton And framework-standard-edition

I'm a beginner in Symfony and I want to know what the differences between these two commands for creating a new project in Symfony.
using website-skeleton :
composer create-project symfony/website-skeleton first-project
using framework-standard-edition :
composer create-project symfony/framework-standard-edition first-project
the composer create-project command looks up the entry on packagist that correlates to the second parameter.
So symfony/website-skeleton points to: https://packagist.org/packages/symfony/website-skeleton while symfony/framework-standard-edition points to: https://packagist.org/packages/symfony/framework-standard-edition which in turn point to their respective repositories on github, which may have different names (as is the case with the framework-standard-edition one)
Those pages contain the version numbers that are being installed. The website-skeleton uses symfony/flex (which adds its own definition to the composer.json in the flex-require section which is not shown on packagist, since it's non-standard stuff), which is not quite informative.
The website-skeleton is the bootstrap for a website on the current version of symfony (which may change in the future, so it may reference a static version at some point in the future or may restrict the version number in some way), which should be symfony 5 right now.
The framework-standard-edition is the bootstrap for a website on the old 3.4.x version of symfony, which probably won't change, since it's already restricted on the version number.
If you're starting on a new project with no restriction to an old php version, you should prefer the website-skeleton.

How to upgrade existing project from Laravel 5.3 to Laravel 5.5?

I am new in Laravel. I want to upgrade my existing Laravel project (a web with Laravel 5.3) to Laravel 5.5 because Laravel 5.3 have different structure than 5.5. If will upgrade all my files will be automatically follow there new directory or I have to made changes to my files to work properly.
It actually depends on your project size, since the estimated upgrade duration is 1-2 Hours, you might simply wish to copy almost all your files (one by one of course) to a newly installed Laravel 5.7, since it's the current latest version. Otherwise you should do it for every version by following the documentation.
https://laravel.com/docs/5.4/upgrade
https://laravel.com/docs/5.5/upgrade
https://laravel.com/docs/5.6/upgrade
https://laravel.com/docs/5.7/upgrade
I usually copy my files over to a new project if the project is small.
Otherwise I simply follow the guide.
Please follow the steps:
open composer.json file and change the version 5.3 to 5.5 and also upgrade the PHP version to at least 7.0
Delete composer.lock file
Delete Vendor Folder
Open Terminal and run the command (composer update).

What files and folders to copy when moving Laravel Project

I'm kinda still finding my way around the Laravel development framework. I want to use a Sample Project Here for my learning
Now the project was done in Laravel 5 and i'm trying to use the Latest 5.5 Laravel.
How do i go about this and what files and folders do i have to copy to my Laravel 5.5 project to get this working.
The file and code structure has changed quite a lot from Laravel 5.0 to Laravel 5.5.
If you are wanting to use that project on Laravel 5.5 then you would need to go through the update process for each version until you reached Laravel 5.5. These can all be found in the Laravel documentation for the respective version.
An easy, and better approach, would just be to incorporate this into your project manually.
SB Admin is just a theme based on Bootstrap and so you can just incorporate it into your app as you would Bootstrap.
You can download the source for SB Admin here - https://startbootstrap.com/template-overviews/sb-admin/
You can also check out the source on GitHub if you need more of an idea on how to use it on specific pages - https://github.com/BlackrockDigital/startbootstrap-sb-admin
If you really want to use that project to learn Laravel then you can. As you're still new to Laravel, I wouldn't bother updating it (you'd likely be in over your head).
To get started with the project, just follow the instructions on their repo - https://github.com/start-laravel/sb-admin-laravel-5:
Clone the project git clone https://github.com/start-laravel/sb-admin-laravel-5.git
Switch into the newly created folder
composer install to install Laravel and the required dependencies
npm install
bower install

Laravel reusing the framework

I am new to laravel , composer and frameworks.however i have managed to install laravel on my pc via composer. and i have created a project with it using
composer create-project laravel/laravel your-project-name --prefer-dist
But i got a directory with my projectname on my current working directory with plenty of files in it.
I need to know wheather i could use this same files by copying the files in the folder and using this as my base for all my other projects..or do i need to run the composer command every time? Even if i run it i gets the same files, which i got now right? So could i just backup the files in the folder i got and use it as my base files?
Well unless you don't have an internet connection there's no point on creating a backup.
Laravel is modular and has external dependencies, so whenever you are creating a new project with composer you are fetching the most recent modules and the most recent Laravel version. But if you use a backup version you might be developing for an outdated version with critical bugs.
Another cool thing is that if you work on different computers, like you have one at work and another at home you don't have to be carrying your backup so you can start a new project by just doing:
composer create-project laravel/laravel your-project-name --prefer-dist
Also I never tested, but I think it takes more time copying a brand new Laravel install with it's dependecies than using composer.
Composer Offline
Another nice thing about using composer is that it stores everything in it's cache. So imagine this scenario we have an internet connection and create a new Laravel app
$ composer create-project laravel/laravel APP1 --prefer-dist
Now disconnect your internet, create another folder and install Laravel again
$ composer create-project laravel/laravel different-APP2 --prefer-dist
When you run the second time and since you don't have internet it will fetch everything from composer cache, but they will be two completely different applications with their own app names and their own application keys
You could use this files again, but you won't get the same files running the command every time, since the latest version of the laravel project and its dependencies are downloaded.
The project files are updated regularly. So if you don't have limited bandwidth, you should just create a new project every time.

Suggestions on how to use version control and composer with symfony2

I'm already half way done with a project in Symfony2.
I need to install a couple of new vendor bundles using composer.
I already have everything (minus logs, cache and parameters.yml) in version control (including the vendor folder).
Problem is when using composer update, it deletes the .svn folders in the vendor folders that where updated. So it's basically impossible to commit now (gives me not a working copy error).
Additional information: I'm working locally and committing to a dev server and then once approved an application server. Therefore it has to be perfect (cannot just run php composer install or php composer update on the dev/application server after commit).
I also tried exporting everything and copying and pasting them back into the repo but that also didn't work (index page broke locally).
Regarding to vendor versioning the best way is not version vendors at all.
The only things you need to version are composer.json and composer.lock. This may cause a problem with vendors which doesn't have stable versions or with that for which you need not stable one (eg. master with particular commit).
As a solution you should create your own (private) vendor repository (let's say your own packagist). Composer has a tool for that, which is called Satis.
https://github.com/composer/satis
So my suggestion would be:
Create a private repository with Satis. You place every package you need in satis.json and whenever you need to update a version of vendor, or add new one, you only modify satis.json and rebuild repository.
In your project's composer.json you set your new private repository as the only repository and set option: packagist to false.
Now, every time you run composer install it will use only your private repository, so it's fast and you always sure that every environemnt has the same versions
-
I was in similar situation two years ago.
The hard lesson I learned was never to edit files within vendor. At first I totally rejected using composer and manually cloned everything I needed. Later on, I decided to fork projects I needed to edit and referenced my forks instead.
Composer supports private GitHub repos - you don't need to register it to Packagist in order to work.
You should not keep your vendor directory in your version control. This is how it is done in Symfony Standard Edition and you should follow this. Running composer install command should be a part of your deployment process
Including vendor packages in your codebase is not recommended, so if you need to maintain the same version of the packages you use on your local machine, the best way is to keep composer.lock in the VCS and running only composer install on other environments.
Additionally, if you want the prod deployment to be instant, without depending on the composer process, you could run composer install on the dev server, and once it's validated you can make your prod deployment script copy the vendor folder from the dev env.

Categories