Know the current version of your Laravel 10 and update

Laravel is the PHP framework by reference and for many reasons it has become the reference web framework and not only in PHP; Laravel follows a custom Model-View-Controller (MVC) architecture since, extending quite a bit to this architecture, Laravel has provides a simple and elegant syntax for developing web applications and a large number of functionalities to develop all kinds of applications.

If there is one thing that makes Laravel stand out, apart from its excellent framework full of various useful features and a most extensible all-terrain framework with both php packages and Node packages, it is because of its development team. that it is always incorporating new features and fixing bugs; and with this constant updates of the most popular php framework today; but this behavior can generate a couple of circumstances that we are going to address in this post:

  • Find out the current version of Laravel installed in your project
  • Update a project in Laravel

Find out the current version of Laravel installed in your project

We are going to learn how we can find out the current version of your project in Laravel: which is a fundamental task when we want to update an existing project to another version, find out if it is convenient for us to update and if this will have a negative impact on our disabled project on partially or totally or on the contrary, the project would be working in a perfect and stable way.

To find out what version of Laravel we are using, just run the artisan command

$ php artisan --version 

At this point, it is recommended that you see the releases on the official Laravel website, obtain information on all the updates that the Laravel team have made and see if any would negatively affect the project you already have created.

Update a project in Laravel

To update a Laravel project, it is recommended to follow the following steps:

  1. Create a backup of your current project in case something goes wrong during the update process and you can check if there are any issues with the stable version.
  2. Check the current version of Laravel you are using and compare it to the most recent version available; to do this, you can use the above command or check your composer.json and search for the Laravel package.
  3. Update composer dependencies by opening terminal in your project directory and running the composer update command. This will update all dependencies to their latest versions.
  4. Update configuration files whose changes are required for the newer version of Laravel; this is somewhat complicated, since many times you have to make additional changes at the project level.
  5. If you have customized your project views, make sure they are still compatible with the new version of Laravel; usually in views there are not many changes to make.
  6. Make sure that the rest of the components are supported by the new version of Laravel; in Laravel, at least the basic resources like controllers, models… are kept intact.
  7. Lastly, test your app and verify that everything works as expected.
  8. It is important to note that additional updates may sometimes be required depending on the specific nature of your project. Therefore, always refer to the official Laravel documentation and perform the necessary tests before deploying the new version to production.

As an additional recommendation, make a list and verify that it is easier, whether to update the project or create a new project and copy the dependencies.

Example of Laravel update to version 10

Now that we know what version of Laravel we have installed on our computer and whether or not we are going to have problems with our project, the next step that remains is to update; for that we have to go to the file called composer.json and look for the package called "laravel/framework": "^10.0" and depending on the version we want to update of Laravel we would have to place the exact version; for example, if we want to update to 1010:

"laravel/framework": "10.10",

Or if we want to update to the latest 10:

"laravel/framework": "^10.0",

We simply specify the "^" character. After you know which version of Laravel you are going to update to, the next thing we will do is execute the following command:

composer update

As you can see, it is a composer command and not a php artisan command, because it is composer that is in charge of updating and installing packages for our project, including our framework.

The command takes a while while it downloads and installs all packages including Laravel; Also remember that when we change versions, many times you have to make additional configurations at the project level.

- Andrés Cruz

En español

Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.