PHP
Iain Poulson, Nov 20

How to Optimize SQL Queries for Faster Sites

Iain Poulson provides a helpful guide to database query optimization, showing how to track down slow database queries and fix them up.
PHP
Christopher Pitt, Nov 16

How to Read Big Files with PHP (Without Killing Your Server)

Christopher Pitt shows how to read and write large files efficiently, using of streams and generators to remove an entire category of application errors.
JavaScript
Karen Teboulle, Nov 15

Essential Skills for Landing a Test Automation Job in 2018

Following our last research, we examined top job searching websites around the world to determine in-demand automation skills and technologies for 2018.
Microsoft Tech
Cormac Foster, Nov 15

Automate CI/CD and Spend More Time Writing Code

An overview of how Microsoft Visual Studio App Center can help you automate continuous integration and continuous deployment to save you time.
Offers
SitePoint Team, Nov 14

Get a lifetime of online privacy with VPN Unlimited for under $45

Special offer for SitePoint readers. Get a lifetime account for VPN Unlimited for just $42.50, to have a lifetime of online privacy.
6 COMMENTs
Web
Craig Buckler, Nov 14

Which Browsers Should Your Website Support?

How do you choose a set of applications from an ever-changing landscape of devices, operating systems and browsers? Craig discusses pragmatic options.
JavaScript
Dan Greenberg, Nov 10

7 Open-Source Test Automation Frameworks

Here are the pros and cons of 7 different open-source test automation frameworks.
JavaScript
Todd Motto, Nov 09

Top 12 Productivity Tips for WebStorm and Angular – Part 2

Todd Motto walks you through his top productivity tips for Angular development with WebStorm.
Web
Mark Schiefelbein, Nov 09

How to Start a Developer Newsletter

Learn how to start your own awesome development newsletter with Revue's Mark Schiefelbein.
Design & UX
Paul Maplesden, Nov 06

How to Supercharge Your Product Design Workflow with CloudApp

We'll show you how to improve your workflow by bringing together teams, communicating smarter, and working on a consistent version of the product.
JavaScript
Michiel Mulders, Nov 01

How to Deploy Node Applications: Heroku vs Now.sh

Michiel Mulders compares Heroku and Now.sh, showing how to deploy Node apps to each service and looking at additional features like monitoring and logging.
Design & UX
Luke Hay, Nov 01

Getting to Know Your Users With Analytics

There’s a lot of data available in your analytics package that will help build up your knowledge of who’s visiting your website.
PHP
Tom Butler, Oct 31

Your First PHP Code

Now that you have your virtual server up and running, it’s time to write your first PHP script. PHP is a server-side language.
Design & UX
Jessica Enders, Oct 31

Designing Form Layout: Color

Human beings are sensitive to color. We process it without us even realizing, and we can’t help noticing differences. This is useful in form design.
JavaScript
Lee Brandt, Oct 30

Build a React App with User Authentication in 15 Minutes

This article originally appeared on the OKTA blog. Thank you for supporting the partners who make SitePoint possible.

React has quickly become one of the most favored front-end web frameworks, and is second only to plain old HTML5, according to JAXenter. So it’s no surprise that developers are learning it, and employers are asking for it.

In this tutorial, you’ll start with a very simple React app with a couple of pages and some routing built in, and add authentication using Okta’s Sign-In Widget. The Sign-In Widget is an embeddable Javascript widget that allows developers to use Okta’s secure, scalable architecture with a minimum of effort from within React applications. Let’s get started!

Get the Simple React Seed Project

Start by cloning the simple React seed project.

git clone https://github.com/leebrandt/simple-react-seed.git okta-react-widget-sample
cd okta-react-widget-sample

Add the Okta Sign-In Widget

Install the Okta Sign-In Widget using npm.

npm install @okta/okta-signin-widget@2.3.0 --save

This will add the Okta Sign-In Widget code to your node_modules folder. We’ll be using version 2.3.0 of the Sign-In Widget.

Okta in node_modules

Then add the styles for the widget in your index.html file from the Okta CDN. Add these lines inside the <head> tag:

    <link
     href="https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/2.3.0/css/okta-sign-in.min.css"
      type="text/css"
      rel="stylesheet"/>

    <!-- Theme file: Customize or replace this file if you want to override our default styles -->
    <link
      href="https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/2.3.0/css/okta-theme.css"
      type="text/css"
      rel="stylesheet"/>

The LoginPage Component

First, create a folder called auth in the ./src/components folder, then create a file called LoginPage.js where the LoginPage component will go.

Start with the most basic of components:

import React from 'react';

export default class LoginPage extends React.Component{
  render(){
    return(
      <div>Login Page</div>
    );
  }
}

This little component doesn't do much but at least you now have a handle to add the LoginPage to your routing. So in your ./src/app.js file, you'll import the component at the top:

import LoginPage from './components/auth/LoginPage';

and then add the route inside the main route (the one with the path of "/")

<Route path="/login" component={LoginPage}/>

Add the OpenID Connect Application in Okta

In order to use Okta as your OpenID Connect provider for authentication, you’ll need to set up an application in the Okta developer console.

If you don't have an Okta developer account, go create one! Once you're logged in, click on Applications in the top navbar, then click Add Application. Select SPA as the platform and click Next. Change the redirect URI to http://localhost:3000, and click Done. The application will be created with the following settings:

OIDC Application Settings

Now that you have an application created in Okta, you can set up the widget to talk to your new app!

Add the Widget to Your Component

import React from 'react';
import OktaSignIn from '@okta/okta-signin-widget';

export default class LoginPage extends React.Component{
  constructor(){
    super();
    this.widget = new OktaSignIn({
      baseUrl: 'https://{oktaOrgUrl}',
      clientId: '{clientId}',
      redirectUri: 'http://localhost:3000',
      authParams: {
        responseType: 'id_token'
      }
    });
  }

  render(){
    return(
      <div>Login Page</div>
    );
  }
}

Copy the Client ID generated from your application's settings page and paste it over {clientId}. Make sure you also replace {oktaOrgUrl} with your Okta organization URL, which you can find by going back to the main Dashboard page in the developer console. Usually it will look like: https://dev-12345.oktapreview.com.

Thus far you've imported the OktaSignIn function from the Okta Sign-In Widget npm module you installed earlier. Next, in the constructor of the component, you initialized an instance of OktaSignIn with the configuration for the application. This way, the application code will be able to talk to Okta and Okta will recognize that this is the app you just created.

Show The Login Widget

Next, you’ll create the code to actually render the Sign-In Widget to the page! You'll need to change your render method to create an HTML element you can render the widget into. Make sure to get a reference to the element that will be rendered. Then, add a componentDidMount function to make sure you don't try to render the widget before the HTML element is on the page.

Design & UX
Jessica Enders, Oct 30

Designing Form Layout: Spacing

Human beings see things that are close to each other as being related. Conversely, things that are not related usually have some space between them.
Design & UX
Jessica Enders, Oct 30

Designing Form Layout: Alignment

Create a straight, unobstructed, vertical path to completion. Now it's faster for your form to be filled out, and it looks neater and simpler too.
PHP
Bruno Skvorc, Oct 30

How to Optimize MySQL: Indexes, Slow Queries, Configuration

Here's a compendium of practical MySQL optimization tricks - from bottlenecks to configuration and indexes. Leave your ORM behind and get your hands dirty!
Design & UX
Emma Howell, Oct 28

Understanding the Core Concepts of User Research

In this section, we’re going to run through 10 concepts. These form the basic building blocks of effective user research design.
Design & UX
Ben Coleman, Oct 28

How to Make Paper Prototypes

There are no rules for making paper prototypes––that is what's great about it. You just need materials that are commonly found in any home or office.
JavaScript
Kaloyan Kolev, Oct 27

Quickly Create Simple yet Powerful Angular Forms

Forms are an essential part of most web applications. Kaloyan Kolev shows how to create template-driven and reactive Angular forms along with validation.
Design & UX
Daniel Schwarz, Oct 27

How to Prototype Interactions with Adobe XD

The following is a short extract from our book, Jump Start Adobe XD, written by Daniel Schwarz, a highly practical tutorial.
Design & UX
Dan Goodwin, Oct 27

UX: What Can We Prototype? What Can't We Prototype?

In this article, we'll look at some of the uses for prototypes -- and also some of the things that you shouldn't use prototypes for.
Ruby
Glenn Goodrich, Oct 25

Understanding the Model-View-Controller (MVC) Architecture in Rails

Rails really takes the idea of separating an application's data, user interface, and control logic to a whole new level. In this article we'll see how.