Useful Composer PHP Package Manager Commands

Useful Composer PHP 7 Package Manager Commands



Composer is fairly easy to update, just run this command:
composer self-update

Composer works by using the configuration in a file called composer.json, where you can
outline external dependencies and your autoloading style. Once Composer has installed
dependencies listed in this file, it writes a composer.lock file that details the exact
versions it has installed. When using version control it is important that you commit this file
(alongside the composer.json file), don’t add it to your .gitignore file if you’re on Git.
This is very important because the lock file details the exact version of a package that was
installed at a particular time in your version control system. You can, however, exclude a
directory called vendor,

So now we can add the following markup to the composer.json file:

  "autoload": {
    "psr-4": {
      "IcyApril\\ChapterOne": "src/"
So let me explain what this file does; it tells Composer to autoload everything in the

So, the next step is to create our src directory where we include the code we want to
autoload. Done that? Right, now let's open up our command line and move into the
directory where we've put our composer.json file.
In order to install everything in the composer.json file in your project just run the
composer install command. For subsequent updates, the composer update command
will update to the latest versions of all dependencies as defined in composer.json. If you
don't want to do this, though, there is an alternative; running the composer dump-autoload
command will solely regenerate the list of the PSR-0/PSR-4 classes that need to
be included in the project (for example, you add, delete, or rename some of your classes).
Now let me cover how you will actually go about creating a class. So, let's create an src
directory in our project and in that src directory create a new class called Book. You can do
this by creating a file called Book.php. In that file, add something like this:

namespace IcyApril\ChapterOne;

class Book
  public function __construct()
    echo "Hello world!";


The line after you put in your PHP opening tag, we need to pull in our autoloader script:

Then we can instantiate our Book class:
new \IcyApril\ChapterOne\Book();

Addition and Multiplication of Matrix in Python 3

Addition and Multiplication of Matrix in Python 3


m1 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]]

m2 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
m3 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]]
m4 = [[1,2,3,4],[4,5,6,7],[7,8,9,0]]
class TwoDimMatrixOp:
def __init__(self, m1, m2):
self._m1 = m1
self._m2 = m2
self._result = [ [0]*(len(m1)-1) for _ in xrange(len(m2)) ]
def sum(self):
# iterate through rows
for i in range(len(self._m1)):
# iterate through columns
for j in range(len(self._m1[i])):
self._result[i][j] = self._m1[i][j] + self._m2[i][j]
for r in self._result:
def multi(self):
self._result_mult = [ [0]*(len(m1)) for _ in xrange(len(m2[0])+1) ]
# iterate through rows of X
for i in range(len(self._m1)):
# iterate through columns of Y
for j in range(len(self._m2[0])):
# iterate through rows of Y
for k in range(len(self._m2)):
self._result_mult[i][j] += self._m1[i][k] * self._m2[k][j]
for r in self._result_mult:
TwoDimMatrixOp(m1, m2).sum()
TwoDimMatrixOp(m3, m4).multi()