Wednesday, May 27, 2020

What Is Composer for PHP and How to Install It

Today, we’re going to discuss one of the most important tools in PHP: the dependency manager Composer. In this article, we’ll look at the ins and outs of Composer and how to install it and use it in your day-to-day PHP development. 

If you’ve been coding in PHP for some time, you'll be aware of how PHP libraries can help save work and make code reusable. In the past, it was harder to add libraries to PHP, which lead to a lot of reinventing the wheel for common features. For example, a DAL (database abstraction layer) is a must-have for any PHP application, but there was no standard library or package, so many people ended up developing their own.

Certainly, there were a lot of options available at that time, but it was difficult to add dependencies, to keep track of them, and to manage your application in the long run. That's where a dependency manager like Composer comes in. In fact, before Composer, there was a popular tool called PEAR which was used to manage PHP extensions and libraries. But it had its own limitations, which Composer was created to address.

In a nutshell, we need a tool which can be used to install libraries and manage application dependencies. Composer does a great job of this, it is application-level package manager for PHP. It has gained immense popularity and it has become the de-facto standard for managing dependencies in PHP applications.

What Is a Composer?

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. — Composer Introduction

It’s important to note that Composer allows you to install necessary libraries on per-project basis. It allows you to use different versions of the same library across different PHP projects. Of course, there’s an option to install a library globally, but it’s not recommended. If you’ve heard of npm for Node.js, or Bundler for Ruby, that's what Composer is for PHP.

To install and use libraries that are managed by Composer, you just need to declare them in your project in a standard format, and Composer will manage the rest. For example, if you want to install the phpmailer library by using Composer, you just need to run the following command in the root of your project.

This installs the phpmailer library and its dependencies in the vendor directory of your project. More importantly, it also creates composer.json and composer.lock files that will be used to track dependencies of your project. We’ll get back to this in detail later in this article.

In fact, Composer has become a global standard when it comes to managing third party PHP libraries. Popular PHP frameworks like Symfony, Laravel, Drupal and many more have already adapted composer based workflow in their development life cycle.

In the next section, we’ll see how to install Composer.

How to Install Composer

When it comes to installing Composer, there are two ways. You could install it either locally per-project basis or globally. We’ll install it globally so that it can be used across different projects.

How to Install Composer on *nix and macOS

For *nix-based systems—Linux and Unix—it just takes a single command to install and run up Composer right away. Go ahead and run the following command in your terminal.

And with that, Composer is installed locally and you are ready to use it with the php composer.phar command! However, we want to install it globally, so let’s do that by executing the following command.

Now, you should be able to use Composer globally. Go ahead and test it to see if it has installed successfully.

On the other hand, if have installed Composer locally, you would run the php composer.phar --version command.

So as you can see, it’s pretty straightforward to install Composer on Linux- and Unix-based systems. In the next section, we’ll see how to install it on Windows systems.

How to Install Composer on Windows

For Windows users, it’s even easier to install Composer. You just need to download the Composer setup executable and run it. Follow along with the installation steps and it’ll install the latest Composer version. You should be able to run composer commands right away.

It’s important to note that you need to restart your terminal after you’ve installed Composer since the PATH variable only gets loaded when the terminal is started.

So that was a brief about installing Composer on different operating systems.

What Is Packagist?

Now, you’re aware of the basics of Composer and how to install it. The next question is how do you know that which libraries are available that you could install with Composer. Is there any central repository where Composer keeps the list of available libraries? Yes: Packagist.

Packagist is the default Composer package repository from where Composer pulls libraries and its dependencies when you ask it to install a specific library. There are hundreds of libraries available on Packagist, which shows the popularity of Composer. In your PHP projects, if you need a feature which you think should be already available as a third party library, Packagist is the first place you to check!

When it comes to searching libraries, Composer is also capable of looking beyond the Packagist repository. You could ask Composer to look at repositories other than Packagist  for installing libraries by altering the repositories key in the composer.json file. In fact, this is what you'll do if you want to manage your own private Composer packages.

In the next section, we’ll see how to use Composer to install libraries in your PHP projects.

How to Use Composer

Mostly, there are two ways when it comes to installing libraries with Composer. Let’s quickly go through it to understand how it works.

The install Command

To use install, you need to create the composer.json file in your project first. In the composer.json file, you just need to declare your project dependencies as shown in the following snippet.

Next, when you run the composer install command from that folder, Composer installs the phpmailer package and its dependencies in the vendor directory. More importantly, it also creates the composer.lock file which maintains a list of all of the packages and the exact versions of them that are installed.

The require Command

We can say that the composer require command is a sort of shortcut for the previous process of crating a composer.json file. require will add a package to your composer.json file automatically. The following command shows how to install the phpmailer package with the help of the require.

After installing the phpmailer package and its dependencies, require also adds an entry of the package which is installed in the composer.json file. If the composer.json file doesn’t exist, it’ll be created on-the-fly. Of course, it also updates the composer.lock file to write package information along with the exact versions.

So that’s how you can install necessary dependencies in your PHP projects by using Composer. And with that, we’ve reached the end of this article as well.

Conclusion

Composer has become the de-facto standard to manage project dependencies in PHP. In this article, we’ve gone through the basics of Composer and how to install it. 

The Best PHP Scripts on CodeCanyon

The free libraries on Packagist are wonderful for basic functionality—the foundation for a good app. However, for more specialized features or for complete applications that you can use and customize, take a look the professional PHP scripts on CodeCanyon

Here are a few of the best-selling and up-and-coming PHP scripts available on CodeCanyon for 2020.



by Sajal Soni via Envato Tuts+ Code

YouTube Is Testing To Integrate Google Search Results With Video Search In Its Mobile App

We have seen that YouTube has been constantly testing and releasing out new features and tools for its Android app. Now, YouTube for Android is testing another feature that will integrate Google results with video search. The new feature was first spotted by a Reddit user. According to a...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Arooj Ahmed via Digital Information World

4 Most High-Demand Skillsets for Remote Jobs

4 Most In-demand Skill Sets for Remote Jobs

Working remotely is on the rise, and will continue to do so long after COVID-19 runs its course. If you’re thinking about ditching the office but aren’t sure how, learning one (or more!) of the following skillsets will increase your chances of landing a remote job.

Software Development

Software development is the most in-demand remote job in the world. And with a median salary of $66,000/year, you can probably afford a decent home office setup in which to operate.

Software development might be the job for you if you like solving problems, building things, and continuous learning. Even the best developers have to jump on GitHub or Stack Overflow from time to time to crowdsource a solution. In fact, development practically necessitates collaboration, making the development community extremely tight and incredibly helpful.

So what skills does a remote software developer need in 2020? Well, a lot of them. Google “software development skills” and you’ll find list upon list of subjects like programming languages, algorithms, databases, and encryption. But good news (and, as you’ll find, a running theme in this article): you don’t have to learn everything.

Instead, choose a software development concentration. For example, going from software development to Java development immediately cuts your required skill set in half. And you don’t have to stop there. Refining your concentration to mobile Java development, or even mobile game Java development, turns a near Herculean task into something much more reasonable.

Digital Marketing

Digital marketing is another wildly in-demand skill set. Digital marketers are responsible for services like social media campaign planning, content coordination, SEO, and PPC ads. Remote digital marketing jobs average a median salary of $50,500/year, and nearly every industry is hiring.

Continue reading 4 Most High-Demand Skillsets for Remote Jobs on SitePoint.


by Joshua Kraus via SitePoint

More security for the users of Google Messages app with end-to-end encryption for the RCS chat system

According to 9to5G, Google is trying to make the RCS messaging end-to-end encrypted. This is wonderful news as it will make the Messaging system more secure and at par with iMessage and WhatsApp. Every phone has a basic SMS system as its default messaging app. Google integrated the Rich...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Arooj Ahmed via Digital Information World

Ten years of responsive web design

#442 — May 27, 2020

Read on the Web

Frontend Focus

Responsive Web Design Turns Ten — Ten years ago the phrase ‘responsive web design’ was first coined. This guiding blog post, outlining the three ‘ingredients’ needed (fluid grids, flexible images, and media queries), soon followed. Here, Ethan takes a look back at just how responsive design came to be.

Ethan Marcotte

Everything New on Microsoft Edge from Build 2020Microsoft Build 2020 took place entirely online for the first time last week but it wasn’t short of announcements and great talks, particularly for MS’s Edge browser. Here's a video roundup of what's new if you'd prefer.

Kyle Pflug (Microsoft)

New Course: Design Systems with Storybook & React — Learn to create a design system from scratch using React, and document the design system to share with your team using Storybook.

Frontend Masters sponsor

Google Fonts Is Fast. Now It’s Faster. Much Faster — Using Google Fonts? It can often prove to be one of the bigger performance bottlenecks, but in this thorough guide Harry Roberts runs through several optimisations you can put in place to make things snappy.

CSS Wizardry

A Complete Walkthrough to Using WebGL — A really detailed walkthrough of getting started with WebGL at the low level, complete with integrated, editable examples and coverage of the math behind 3D rendering. If you’ve ever wondered what libraries like Three.js are using behind the scenes, it’s all here.

Maxime Euzière

⚡️ Quick bits:

💻 Jobs

Frontend Developer at X-Team (Remote) — Join X-Team and work on projects for companies like Riot Games, FOX, Coinbase, and more. Work from anywhere.

X-Team

Find a Job Through Vettery — Vettery specializes in tech roles and is completely free for job seekers. Create a profile to get started.

Vettery

ℹ️ Interested in running a job listing in Frontend Focus? There's more info here.

📙 Tutorials & Opinion

How to Tame Line Height in CSS — Caleb Williams looks at the line-height property, “probably one of the most misunderstood, yet commonly-used attributes”.

CSS Tricks

▶  How to Center an Element Horizontally and Vertically with Flexbox — You’ve heard all the jokes about the difficult of center aligning things with CSS, but laugh no more as Ali demonstrates how to do it in just a minute.

Ali Spittel

Local Testing on an iPhone — You should be testing on a real-world mobile device, so here’s a nice and quick way to get your localhost server running on an iPhone with the help of ngrok.

Josh Comeau

The State of Micro Frontends — “One of the more controversial topics in frontend web dev is microfrontends. Are they worth it? Should you really split up your application?

Florian Rappl

Here’s What I Didn’t Know About “content — You’ll no doubt learn something here.

Manuel Matuzović

How to Make a Simple CMS with Cloudflare, GitHub Actions and Metalsmith — Let’s say you want to build a CMS but don’t want to mess with the fiddly UI bit.. how about using GitHub itself? Couple that with the Metalsmith static site generator and Cloudflare Workers.. and here you go.

Jon Paul Uritis

target="_blank" - The Most Underrated Security Vulnerability — Why rel="noopener" should be added to links containing target="_blank" as a precaution against reverse ‘tabnabbing’.

Manjula Dube

▶  Using Chrome DevTools Console Utilities to Make Debugging Easier

Tomasz Łakomy

🔧 Code, Tools and Resources

instant.page 5: A Way to Make Your Site's Pages Feel Faster — A reasonably simple piece of JavaScript you can drop onto a page that adds link preloading (upon mouse or pointer hover on a link) to make page transitions seem unnaturally fast.

Alexandre Dieulot

Tailblocks: Ready-to-Use Tailwind CSS Blocks — This is a set of 60+ ready-to-use UI blocks built with Tailwind, the popular CSS framework. 15 categories of blocks, which you can preview here.

Mert Cukuren

Blunt: A CSS Framework That Helps with Layouts and Leaves Your Styling Alone — This is a little different. This framework doesn’t have any effect on design visuals, it only provides helper classes for positioning and responsive layouts.

Frankie

LaTeX.css: Make Your Site Look (More) Like a LaTeX DocumentLaTeX is a popular typesetting system frequently used in academia and mathematic or scientific documentation.

Vincent Dörig

Howler.js: An Audio Library for The Modern Web — Makes things easier cross-platform. Uses the Web Audio API but can fall back to HTML5 Audio.

James Simpson

LineIcons: 2000+ Free Line Icons for Designers and Developers — A nice looking set of line-based icons, categorized, and available in a number of different formats including web font, SVG, AI, and more.

LineIcons

A Pure CSS 'Oil Painting' — Another amazing effort, this time of an Italian-style renaissance painting, from CSS artist Diana Smith. Related repo.

Diana Smith


by via Frontend Focus

Facebook’s act of ignoring the reports of divisive algorithms suggest that there is ‘trouble in paradise’

There has been quite a shocking news making rounds. According to a report from the Wall Street Journal, all is not well amongst the higher level of Facebook’s officials. There was an internal report that Facebook’s employees presented to the executives in 2018. That report suggested that Facebook’s...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Arooj Ahmed via Digital Information World

Article: How to request the perfect Landing Page testimonial from a customer

In this article I suggest a three-step method to help generate great Landing Page testimonials from your customers.

So what does a great testimonial look like?

For a little context, to help promote my upcoming course I’m publishing 1 Landing Page “hot tip” for 100 days in a Twitter thread or email drip.

The first was a fictitious lesson how we should try utilize testimonials to further highlight features & answer doubts:

 

Landing Page Hot Tip #01

 

This naturally kicked off a discussion if it’s ok to create fake testimonials in our Landing Pages?

It’s not.

The lesson demo unfortunately had little context but was intended to showcase what kind of testimonials to handpick out your collection.

“But what if all my testimonials are a bit meh?”

Here is my three-step method to generate a great customer testimonial:


Step 1: Request a detailed testimonial

The goal here is to receive a lot of text we can edit into a great testimonial.

Your request to your customer could be as follows:

If you are after a specific attribute for your Landing Page, add this paragraph just above the coupon:


Step 2: Edit the testimonial, extracting highlights

Kim sent us 44 words:

Taking into account the lesson from earlier, a great testimonial highlights features (the superb quality) and answers doubts (the glass breaking) so I’ve refined the testimonial down to this:

So glad I could finally experience their superb quality myself and was really impressed by the thoughtful packaging of such a delicate item.


Step 3: Confirm your edit with your customer

And that’s it!

Yup, a considerable amount of extra effort but worth it. A handful of brilliant testimonials relevant to your visitor (i.e potential customer) is how we can really strengthen our Landing Page.

Subscribe to my Landing Page Masterclass mailing list and get more articles like this leading up to the release.


by Rob Hope @robhope via One Page Love