How to Uninstall/Remove Package in Laravel?

composer remove VenderName/PackageName – The remove command removes packages from the composer.json file from the current directory.

Syntax :- composer remove VenderName/PackageName

Syntax:- composer remome VenderName/PackageName1

VenderName/PackageName2

If you want to remove more than one package then you have to run this command.

Ex:- composer remove fzaninotto/faker

–dev: It remove packages form require-dev

This means, if it is in require-dev, then you have to remove it from there, then for this, you have to flag the dev.

Ex: composer remove fzaninotto/faker –dev

Tagged : / / /

How to Install/Add-Package in Laravel?

composer require VendorName/PackageName – This command installs a package and any packages that it depends on.

syntaxexample
composer require VendorName/PackageNamecomposer require fzaninotto/faler
composer require VendorName/PackageName:tagcomposer require fzaninotto/faker:dev-master
composer require VendorName/PackageName:versioncomposer require fzaninotto/faker:1.9.0

–dev: Add packages to require-dev.

composer require VendorName/PackageName –dev

https://packagist.org/ This is the website, from where you will get Php packages. This is the package repository of Php. You have to open this site, whatever your requirement is, you can do that package.

If you want a viewer with PDF, then you search by typing PDF. Here the first one wants Dompdf / Dompdf, so I clicked on it. After clicking on it, it will show you what is the version tag. And it will also show how to install it. So to install it, you have to type the command composer require dompdf/dompdf.

Before running this command, you should check that the composor.json file which you have is empty. That is, our project is not dependent on anyone. But now we have the requirement of this project so we will run this command.

Tagged : / / / /

How to set up a new or existing package?

Manually Creating composer.json file

You have to create a composer.joson file and write JSON code yourself with the required properties.

  • composer config –global(-g) – Operate on the global config file located at $COMPOSER_HOME/comfig.json by default. Without this option, this command affects the local composer.json file.
  • composer config –list (-l) __ It shows all the current config variables.
  • composer config setting-key “setting-value” – It sets the config key to the value.
  • composer config –unset – It removes the configuration element named by setting-key.
  • composer config –editor (-e) – Opens the config file (composer.json) in an editor. Use the –global flag to edit the congif (config.json).

Keys:

  • name
  • version
  • type
  • description
  • license
  • homepage
  • keywords
Tagged : / / / /

How do you create a composer.json file by using this command in your project?

We need to create a folder in xampp server. I am going to the local server (C /Drive ) then going to xampp server. Here at htdocs. Then here we will create a project folder that will run on the server.

I will need a text editor I am using Visual studio code you can use notepad, notepad++, sublime text anything.

Then Visual Studio Code has to be opened. After that open folder cmp has to go there location me c/drive/xampp/htdocs/ after that select project folder cmp. Here my project folder has been opened.

Here we create a file index.php and write the code of the PHP in it. And if we need to start the server, then we have to go to Windows Search and search xampp. After that open it and start the Apache server.

After this, we have to run on the tube, for that we have to do a few searches in the search in Windows Manu and open the Run Administrator.

After that, we have to go to my own project of CMD.
Tagged : / /

What is composer.JSON? How do I use it?

A file is generated from the composer tool. Which is the main file of the whole project which we call the composer file. The extension file is composer.json. It is the main composer.json that defines your project requirements.

How to setup a new or existing package

You can also say how to create a composer.json file in a Project to make it a package.

  • Ussing composer init Command
  • Manually Creating composer.json file

Ussing composer init Command

composer init – It is used to set up a new or existing package. The init command creates a basic composer.json file in the current directory.
Every project is a package.
As soon as you a composer.json in a directory, that directory is a package.

composer.json

Package name – in order to make that package installable you need to give it a name. It consists of vendor name and project name, separated by/. The name can contain any character, including white spaces, names are case insensitive, the convention is all lowercase and dashes for word separation. It is required for published packages(libraries).

Syntax:- vendorname/packagename

Ex:- devopsschool/dev

Description- A short description of the package. Usually, this is one line long. It is required for published packages(libraries).

Authors – The authors of the package. This is an array of objects.

Each author object can have the following properties:

  • name: The author’s name. Usually their real name.
  • email: The author’s email aaddress.
  • homepage: An URL to the author’s website.
  • role: The author’s role in the prject (e.g. developer or translator)

Minimum Stability – Composer accepts these flags as minimum-stability settings. The defualt setting for minimun-stability if not provided is assumed to be stable, but you sould define any of the flags down the hierarchy.

  • stable (most stable)
  • re
  • beta
  • alpha
  • dev (least stable)

Package Type – Package types are used for custom installation logic. If you have a package that needs some special logic, you can define a custom type. It default to library.

  • Library
  • Project
  • Metaapackage
  • Composer-plugin

License – The license of the package. This can be either a string or an array of strings.

Ex:- MIT

Tagged : / / / /

How to Install Composer in Laravel?

Composer requires PHP 8.0+ to run

  • Download Composer exe from official website then install it
  • Use command line installation

-May need to set Path or use php composer.phar init

Go to the windows search menu and type cmd

Open Command Prompt then right click and go to Run as administrator

Then show you screen c:\Windows\system32>
and then type composer -V and press enter bottom.
If your composer is already installed then your computer screen will show the composer version. And if not already installed it will show – Composer is not recognized unknown internal and external commands, compatible programs, and batch files.

How to Update Composer

There is some new update in composer, so if you want to update it then you have to run command for it:

composer self-update

How to Roll Back Composer Update

If that update starts happening, then you can roll back that update and go back to the old versions. For which you have to run the command:

composer self-update –rollback

Tagged : / / / /

How to use Composer in Laravel?

What is Composer?

Composer is a tool dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) than for you. Composer is not a package manager in the same a Yum or Apt are. Yes, it deals with “packages” or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. vendor) inside your project. By default, it does not install anything globally. Thus, it is a dependency manager. It does however support a “global” project for convenience via the global command.

Why use Composer?

  • You have a project that depend on a number of libraries.
  • Some of thoes libraries epen on other libraries.
  • Enable you to declare the libraries you depend on.
  • Find out which versions of which packeges can and need to be installed, and installs them.

You have a project that depends on several libraries. The libraries that I used in my project to create PDF are also supported by other libraries. It gives you the urgency to declare those libraries that you are on these libraries as it will manage them all for you. It will find out which packages are required for the project we have. Which version of the package is required and will install it for you.

Tagged : / / / /

PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version “>= 7.2.5”. You are running 7.1.32.

When you using PHP version 7.1.32 within your Laravel project, then showing this type of error in your project. If you want to update the composer still not solve you problem then After that Follow this trick-

add this line in config object of composer.json file

“platform-check”: false

run php artisan config:cache

then run composer dump-autoload in terminal

Tagged : / / / / / / / / / /