Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sebastian De Deyne:
TypeScript With Laravel Mix
May 25, 2017 @ 15:21:16

In a post to his site Sebastian De Deyne shows how to use Laravel Mix to work with Typescript right alongside other packages and libraries included in your mix configuration.

In a recent Spatie project we decided to give TypeScript a shot for the business critical part of a new application. TypeScript provides static analysis to reduce the chance of introducing bugs, to have self-documenting code, and to improve our tooling (autocompletion!)

We've been happily using Laravel Mix since it's release with Laravel 5.4. Luckily, extending Mix isn't too hard with some webpack knowledge. [...] As long as you've configured an appropriate loader, you could import anything from a plain old JavaScript file to an animated gif. This means that if we want to support TypeScript with Laravel Mix, we don't need to change any configuration, we only need to add the ability to bundle TypeScript files.

The remainder of the article is broken down into the four steps (and a bonus) for getting Mix and TypeScript playing together nicely:

  • Install The Necessary Dependencies
  • Configure TypeScript
  • Configure Laravel Mix
  • Write Some TypeScript!

The bonus at the end shows how to use this working setup to go one step further and use TypeScript in the Vue.js components in your Laravel application.

tagged: laravel laravelmix typescript combination tutorial configuration

Link: https://sebastiandedeyne.com/posts/2017/typescript-with-laravel-mix

Symfony Finland:
A practical introduction to TypeScript for PHP developers
Feb 06, 2017 @ 16:14:22

The Symfony Finland blog has posted a practical introduction to Typescript for PHP developers. TypeScript is a free and open-source programming language developed and maintained by Microsoft. It is a strict superset of JavaScript, and adds optional static typing and class-based object-oriented programming to the language.

A greenfield project might be a good way to try a technology, if the scope is limited and risk in general is low. For many kicking off a new project or undertaking a major rewrite is not an option, but you can still evolve and apply good ideas and fresh concepts in your work. The value of legacy in web development is understated.

This is an area I've found TypeScript to be very useful for and I think many developers can benefit from taking a closer look at it. TypeScript compiles down to JavaScript & can be adopted gradually, chances are you'll have plenty of code you can use it on.

They then cover five advantages about TypeScript that can help make adoption in your applications easier:

  • Low overhead in getting started
  • Great tooling for your favourite editor
  • Familiar syntax for async programming
  • Type Definition files
  • Stability and adoption

For each section there's a brief summary of the point and, where applicable, a quick code example or screencast animation showing it in action.

tagged: practical introduction typescript javascript tutorial adoption

Link: https://www.symfony.fi/entry/a-practical-introduction-to-typescript-for-php-developers


Trending Topics: