How To Install and Use PHP Composer on Ubuntu 18.04

Introduction

PHP Composer is an application that tracks dependencies for a project. It does not replace system package managers like apt or yum.

Composer allows you to specify a set of libraries for a specific project then identifies the versions and dependencies and installs them.

This guide will show you how to install and get started with PHP Composer in Ubuntu 18.04.

tutorial on installing and using php composer on ubuntu

Prerequisites

Steps For Installing PHP Composer on Ubuntu

Step 1: Update Local Repository

Start by updating the local repository lists by enter the following in a command line:

sudo apt-get update

Step 2: Download the Composer Installer

To download the Composer installer, use the command:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

Step 3: Verify Integrity of the Download

1. Visit the Composer Public Keys page. Copy the Installer Signature (SHA-384).

2. Set the code shell variable:

COMPOSER=48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5

3. Run the script below to compare the official hash against the one you downloaded:

php -r "if (hash_file('SHA384', 'composer-setup.php') === '$COMPOSER') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

The script will either tell you the download is verified, or that it has been corrupted. If it’s corrupted, re-download the file.

Step 4: Install PHP Composer

1. Installing PHP Composer requires curl, unzip, and a few other utilities. Install them by entering the following:

sudo apt-get install curl php-cli php-mbstring git unzip
install supporting software for composer

Install Composer as a command accessible from the whole system.

2. To install to /usr/local/bin. enter:

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

The installer should output:

All settings correct for using Composer
Downloading...

Composer (version 1.6.5) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

3. Once the installer finishes, verify the installation:

composer --version

The system should output the version number installed, for example:

Composer version 1.8.6 2019-6-11 15:03:05

4. To remove the installer:

php -r “unlink(‘composer-setup.php’);”

Basic Composer Usage

Composer is designed to track dependencies on a per-project basis. This makes it easier for other users to create the same environment. Composer uses a composer.json file to keep track of required software and allowed versions.

It also uses a composer.lock file to maintain consistency if someone copies the directory. These files are automatically generated using the require command.

1. Open a terminal, and enter the following:

mkdir c_sample
cd c_sample

2. Next, you’ll need to choose a package to load. The website packagist.org has a broad range of different PHP packages for download. In this example, let’s use the monolog/monolog package. You can follow the instructions, or search the website for monolog.

3. In the terminal window, enter:

composer require monolog/monolog

The system will download the software and create the composer.json and composer.lock files.

Note: Monolog is a package for managing logfiles. The name before the slash is the vendor, and the name after the slash is the package name.

4. Once the process completes, list the contents of the directory:

ls -l

You should see the composer.json and composer.lock files, along with a vendor directory.

5. To view the contents of the composer.json file:

cat composer.json

The system will show you that it has added the monolog software. The carat ^ sign beside the version number indicates the minimum version of the software.

Setting Up Autoloading

PHP doesn’t automatically load classes. However, you can configure Composer to autoload classes for you. This makes working with dependencies much easier.

1. Create a new file using your favorite text editor:

sudo nano composer_sample.php

2. Enter the following into the file:

<?php

require __DIR__ . '/vendor/autoload.php';

use Monolog\Logger;

use Monolog\Handler\StreamHandler;

 

// create a log channel

$log = new Logger('name');

$log->pushHandler(new StreamHandler('/~/c_sample/text.log', Logger::WARNING));

 

// add records to the log

$log->warning('Foo');

$log->error('Bar');
example of autoloading classes

3. Write the file (Ctrl+O), and exit (Ctrl+X).

4. Now you can run the command to autoload monolog:

php composer_sample.php

Updating Dependencies

To update all the dependencies in your composer.json file enter the command:

composer update

This will update all dependencies according to the version specified in the file.

To update one (or more) dependencies individually:

composer update vendor/package vendor_b/package_b

Conclusion

Now you have a good understanding of how to install and start using PHP Composer. We also covered setting up autoloading and updating dependencies.

Installation and Configuration of Virtualmin/Webmin in Ubuntu 20.01 with Multiple PHP version and MariaDB

Install Virtualmin on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade
sudo apt install software-properties-common apt-transport-https wget

Step 2. Installing Virtualmin on Ubuntu 20.04.

Before installing Virtualmin, now we install Webmin because Webmin uses a plugin called Virtualmin to simplify the management of multiple virtual hosts through a single interface, similar to cPanel or Plesk.

Now install Webmin using the official repository on both Debian and non-Debian-based systems. We can install Webmin using the Webmin APT repository on Ubuntu as shown below:

sudo nano /etc/apt/sources.list
# Add these lines at last
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

# Save and exit the editor

Next, install the GPG key as shown below. We need the GPG key to trust the repository:

wget -q http://www.webmin.com/jcameron-key.asc -O- | sudo apt-key add -

Now we can install the most recent version of Webmin using the following commands:

sudo apt update
sudo apt install webmin

Step 3. Configure Firewall.

By default, Webmin listens for connections on port 10000 on all network interfaces. You need to open the port in your firewall so that the Webmin interface is accessible from the Internet:

sudo ufw allow 10000
sudo ufw reload

Step 4. Accessing Webmin Web Interface.

To login to Webmin’s dashboard, open up your browser and browse your server’s IP as follows:

https://your-server-ip-address:10000/

Step 5. Installing Virtualmin on Ubuntu 20.04.

Virtualmin provides an install script that allows for an easy installation. Run the commands below to download the Virtualmin script:

curl -O http://software.virtualmin.com/gpl/scripts/install.sh

Once downloaded, make the script executable:

sudo chmod +x install.sh

Finally, run the commands below to install Virtualmin:

sudo ./install.sh

The script will display a warning message about existing data and compatible operating systems. Press y to confirm that you want to continue the installation.

Step 6. Accessing Virtualmin Web Interface.

Virtualmin web-based monitoring will be available on HTTPS port 10000 by default. Open your favorite browser and navigate to http://your-domain.com:10000 or http://server-ip-address:10000.

Congratulations! You have successfully installed Virtualmin. Thanks for using this tutorial for installing the Virtualmin on your Ubuntu 20.04 LTS Focal Fossa system.

Multiple PHP Versions

## Installing PHP 5.6 and/or 7.4 and/or 8.0 on Debian 9/10

# Enable the [DEB.SURY.ORG](https://deb.sury.org/#debian-dpa “DEB.SURY.ORG”) repository:

apt-get -y install apt-transport-https lsb-release ca-certificates curl
curl -sSL -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

# Update all repositories:

apt update

# Install PHP packages version 5.6 and/or 7.4 and/or 8.0:

apt-get install php5.6-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php7.4-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php8.0-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}

Lastly, see the information on [configuring the second PHP version](#toc-configuring-the-second-php-version-in-virtualmin-ooq1ksVU “configuring the second PHP version”) below.

## Installing PHP version 5.6 and/or 7.3 and/or 8.0 on Ubuntu 16.04, 18.04 and 20.04

# Install the PPA:

add-apt-repository ppa:ondrej/php && apt-get update

# Install the PHP packages:

apt-get install php5.6-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php7.3-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php8.0-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}

Lastly, see the information on [configuring the second PHP version](#toc-configuring-the-second-php-version-in-virtualmin-ooq1ksVU “configuring the second PHP version”) below.

## Configuring the second PHP Version in Virtualmin

Once you have completed the installation of a second PHP version on your server, you can verify that Virtualmin sees it by logging into Virtualmin, and clicking System Settings -> Re-Check Config. You should see something like this:

The following PHP versions are available : 5.3.3 (/usr/bin/php-cgi), 5.6.25 (/opt/rh/rh-php56/root/usr/bin/php-cgi), 7.0.10 (/opt/rh/rh-php70/root/usr/bin/php-cgi)

You can configure which one is the default PHP version used on new Virtual Servers. The default is to use the newest available. You can change that default in System Settings -> Server Templates -> Default -> PHP Options, and on that screen you can set the default PHP version to use in the field **Default PHP version**.

## Configuring Individual Virtual Servers

You can configure the PHP version being used for a specific Virtual Server by selecting Server Configuration -> PHP Versions.

The first line there specifies what PHP version will be used by default.

If you wish, you can specify a different PHP version to be used for a specific directory.

Source: https://idroot.us/install-virtualmin-ubuntu-20-04/

https://www.virtualmin.com/multiplephp/

PHP script not executing on Apache server

Update for php7.x (tested on Ubuntu 16.04, 16.10, 18.04, 18.10)

Thanks to the comments, I update the answer for php7.x.

Install:

sudo apt-get install apache2 php7.x libapache2-mod-php7.x 

Verify:

a2query -m php7.x

Load:

sudo a2enmod php7.x

Restart apache:

sudo service apache2 restart

Multiple PHP Versions on Virtualmin

Multiple PHP Versions


Introduction

If you have multiple PHP versions installed, Virtualmin allows you to choose which version to use for a given domain, or even per-directory.

While this feature can work with any Linux distribution, it works best with 64 bit [CentOS (6 and above)](#toc-installing-php-72-on-centos-6-and-7-yTjimn_w “CentOS (6 and above)”) using the CentOS Software Collections repository, or on [Debian 10](#toc-installing-php-56-70-71-72-73-on-debian-10-buster-EkAj9qSJ “Debian 10”) using a PPA, or on [Ubuntu 14.04](#toc-configuring-the-second-php-version-in-virtualmin-ooq1ksVU “Ubuntu 14.04”) using a PPA.

Installing PHP 7.3 on CentOS 6 and 7

Notes about CentOS

  •  CentOS has a special repository called “Software Collections”, which is a system for installing multiple software versions on one server. Using packages provided by in the Software Collections repository, it’s possible to install more recent PHP versions /opt/, while keeping the default PHP version installed in /usr/.
  • The repository providing these packages currently only provides 64 bit packages. If you are using 32 bit CentOS, there are unfortunately no PHP packages for that.

Install the SCL Repo

yum -y install centos-release-scl

Install the PHP packages

yum -y install rh-php73-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}

Installing PHP 7.4 and/or 8.0 on CentOS 7

Install Remi Release repo and clear cache

yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm && yum clean all

Install PHP packages version 7.4 and/or 8.0

yum -y install php74-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}
yum -y install php80-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}

Installing PHP 7.3, 7.4 and/or 8.0 on CentOS 8

Install Remi Release repo and clear cache

dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm && dnf clean all

Install PHP packages version 7.3 and/or 7.4

dnf -y install php73-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}
dnf -y install php74-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}
dnf -y install php80-php-{cli,pdo,fpm,zip,gd,xml,mysqlnd,opcache}

Installing PHP 5.6 and/or 7.4 and/or 8.0 on Debian 9/10

Enable the deb.sury.org repository

apt-get -y install apt-transport-https lsb-release ca-certificates curl
curl -sSL -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

Update all repositories

apt update

Install PHP packages version 5.6 and/or 7.4 and/or 8.0

apt-get install php5.6-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php7.4-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php8.0-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}

Installing PHP version 5.6 and/or 7.3 and/or 8.0 on Ubuntu 18.04 and 20.04

Install the PPA

add-apt-repository ppa:ondrej/php && apt-get update

Install the PHP packages

apt-get install php5.6-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php7.3-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}
apt-get install php8.0-{cli,pdo,fpm,zip,gd,xml,mysql,cgi}

Configuring the second PHP Version in Virtualmin 

Once you have completed the installation of a second PHP version on your server, you can verify that Virtualmin sees it by logging into Virtualmin, and clicking System Settings -> Re-Check Config. You should see something like this:

The following PHP versions are available : 5.3.3 (/usr/bin/php-cgi), 5.6.25 (/opt/rh/rh-php56/root/usr/bin/php-cgi), 7.0.10 (/opt/rh/rh-php70/root/usr/bin/php-cgi)

You can configure which one is the default PHP version used on new Virtual Servers. The default is to use the newest available. You can change that default in System Settings -> Server Templates -> Default -> PHP Options, and on that screen you can set the default PHP version to use in the field Default PHP version.

Configuring Individual Virtual Servers

You can configure the PHP version being used for a specific Virtual Server by selecting Server Configuration -> PHP Options.

The first line there specifies what PHP version will be used by default.

If you wish, you can specify a different PHP version to be used for a specific directory.

phpoffice/phpspreadsheet[1.18.0, …, 1.20.0] require ext-zip * -> it is missing from your system. Install or enable PHP’s zip extension.

composer require <vendor><package name>

Error:

phpoffice/phpspreadsheet[1.18.0, …, 1.20.0] require ext-zip * -> it is missing from your system. Install or enable PHP’s zip extension.

Answer:

Install using (to install the default version):
sudo apt install php-zip

Or, if you’re running a specific version of PHP:

# For php v7.0
sudo apt-get install php7.0-zip

# For php v7.1
sudo apt-get install php7.1-zip

# For php v7.2
sudo apt-get install php7.2-zip

# For php v7.3
sudo apt-get install php7.3-zip

# For php v7.4
sudo apt-get install php7.4-zip

alexa

[pmpro_levels]

Title 5

Чакащи поръчки и Списък за наблюдение за <ДАТА>;

<Инструмент>

  1. Тренд<тренд>
  2. Зона<тойности на зоната>
  3. Сигнал<екшън прайс сигнал - пин бар, фейки или каквото друго добавим>
Параметри на сделката:
  • Вход: <стойност на входа>
  • SL: <стойност на стоп лос>
  • TP: <стойност на таргет>
  • Риск : Възнаграждение = <стойност на R:R>

"<Инструмент

 

Забележка 1: Ако изпуснете вход на дадена сделка, може да прочетете тук за алтернативен начин да се влезеКак се търгуват моите прогнози?
Забележка 2: От изключително значение е да търгувате с брокер, който предлага истинска графика тип ‘New York Close Charts‘, (истинска 5-дневна графика, която съвпада с New Zealand Open и New York Close). Можете да свалите демо или да се регистрирате, за да тествате от ТУК
Забележка 3: Моите прогнози и анализи не са съвет или препоръка за търговия или инвестиране, а само образователна и обща информация. Не купувайте и продавайте на сляпо пазарите/продуктите, обсъждани в този бюлетин, направете свои собствени проучвания и осъзнавайте рисковете и възнагражденията.
Забележка 4: Всички графики са на ДНЕВНА времева рамка, освен, ако изрично не съм посочил, че е друго.

Convert excel file to multiple csv files

Task

Hello,
I need a tool to create from Excel file multiple CSV files. My first thought is to have it done through Macro (VBA). I am trying to describe the structure dynamically, so the macro could be reused for similar projects, but if this will bring up the costs, I will have to go for the “quick and dirty” solution.
So the goal of the project is defined, “how to” deliver is still open, we can discuss.

I am looking for someone who can deliver rather quickly – lets say 1-2 weeks max (for production version).

Everything is described in the attached Word file. In the file, there are 3 inserted XLS files (objects) – please make sure to review them as well.

Thank you

Attachment

Jupiter export to CSV

Excel VBA expert needed

Task

This is a very simple project.
I need this done quickly after being hired.

Ignore the $999 budget and bid what you believe is fair.

Open the attached workbook.

This is a simple Excel-based CRM.
New leads are loaded in the “new” tab.
The current database of leads is in the “main” tab.

The user will place new leads in the “new” tab and we need a script/macro that will move the new leads from the “new” tab into the “main” tab.
However, we do NOT want duplicates added.

Your script will clean up all the URLs (column A) from the “new” tab and remove the “www.” so we are left with the rest of the domain name (e.g.:  “www.yahoo.com” will be converted to “yahoo.com”).
Next your script will compare the URLs against the company names (column A) in the “main” tab.
If there are duplicates these rows will be ignored.
The remainder URLs will be appended to the “main” tab

In the workbook, the “new” tab has two duplicate records (fenixlighting.com and brightguy.com).
Thus the remaining records in the “new” tab (the URL and the phone number) are appended to the “main” tab.
After the append is done, the “new” tab is cleared out (from row 2 and down).

Attachment

crm-19-12-15 (2)

Excel macros workbook

Task

This project needs to be done today.
You will need to be ready to start work upon being hired on 1/12/2020 @ 8am PST (California time).
Please ignore the budget of $999 and bid what you believe is fair.

Excel VBA expert needed to add calculations script/macros to the attached file.
This is a pricing tool.

The user inputs data into the green column headers of the first tab (“input” tab).
The user is interested in 4 items (marked with an “x” in “Check” column A.
Of these 4 items, the user knows the quantity he needs for 3 of them (cells B2, B5, B6)
The user had ordered 1 of the 4 items before at the price and quantity specified (cells I5 and I6).

The user inputs quantity discounts in the “discounts” tab.
There are only four rows here, but the user can add as may as he wants with different quantity ranges.

The “output” tab takes the 4 items the user wants and attempts to calculate pricing based on the quantity requested.

When your script is run it will take the 4 items requested in the “input” tab and create a table in the “output” tab.
It will then attempt to calculate the quantity pricing for the items that had not been purchased in the past (rows 2, 3, and 5 of the “Output” tab). Look inside the calculations to see how the quantity pricing was calculated (F2:I2, F3:I3, F5:I5).
The “Total” (column J of “output” tab) is calculated based on the quantity desired.
Next, your script will calculate the quantity pricing for items that had been ordered in the past (row 4).
Look at rows F4:I4 of the “output” tab to see how it was calculated. Please note, these cell formulas refer to the “discount” tab’s text that is grayed out. The reason it is grayed out is that, the actual workbook will not show any of this gray text. I am only showing it to show you how it was calculated.
After all the rows are calculated in the “Output” tab, the “Total” (row 6) of the “Output” tab is calculated.
Finally, the columns K and L of the “input” tab are populated from the resulting data from the “Output” tab. Feel free to look inside the formulas to see where it comes from.

So, in summary, your script will use the data from the “Input” and the “Discount” tabs to generate the table from scratch in the “Output” tab. Once the “Output” tab is populated, the “Input” tab’s columns K and L will be populated referencing the data in the “Output” tab.

Attachment

price generator 3