How to Create a Custom Authentication Guard in Laravel

In this article, we’re going to cover the authentication system in the Laravel framework. The main aim of this article is to create a custom authentication guard by extending the core authentication system.

Laravel provides a very solid authentication system in the core that makes the implementation of basic authentication a breeze. In fact, you just need to run a couple of artisan commands to set up the scaffolding of an authentication system.

Moreover, the system itself is designed in such a way that you could extend it and plug in your custom authentication adapters as well. That’s what we’ll discuss in detail throughout this article. Before we go ahead and dive into the implementation of the custom authentication guard, we’ll start with a discussion of the basic elements in the Laravel authentication system—guards and providers.

The Laravel authentication system is made up of two elements at its core—guards and providers.

You could think of a guard as a way of supplying the logic that’s used to identify the authenticated users. In the core, Laravel provides different guards like session and token. The session guard maintains the state of the user in each request by cookies, and on the other hand the token guard authenticates the user by checking a valid token in every request.

So, as you can see, the guard defines the logic of authentication, and it’s not necessary that it always deals with that by retrieving valid credentials from the back end. You may implement a guard that simply checks the presence of a specific thing in request headers and authenticates users based on that.

Later in this article, we’ll implement a guard that checks certain JSON parameters in request headers and retrieves the valid user from the MongoDB back end.

If the guard defines the logic of authentication, the authentication provider is responsible for retrieving the user from the back-end storage. If the guard requires that the user must be validated against the back-end storage then the implementation of retrieving the user goes into the authentication provider.

Laravel ships with two default authentication providers—Database and Eloquent. The Database authentication provider deals with the straightforward retrieval of the user credentials from the back-end storage, while Eloquent provides an abstraction layer that does the needful.

In our example, we’ll implement a MongoDB authentication provider that fetches the user credentials from the MongoDB back end.

So that was a basic introduction to guards and providers in the Laravel authentication system. From the next section onwards, we’ll focus on the development of the custom authentication guard and provider!

Let’s have a quick look at the list of files that we’ll implement throughout the course of this article.

  • config/auth.php: It’s the authentication configuration file in which we’ll add an entry of our custom guard.
  • config/mongo.php: It’s the file that holds the MongoDB configuration.
  • app/Services/Contracts/NosqlServiceInterface.php: It’s an interface that our custom Mongo database class implements.
  • app/Database/MongoDatabase.php: It’s a main database class that interacts with MongoDB.
  • app/Models/Auth/User.php: It’s the User model class that implements the Authenticable contract.
  • app/Extensions/MongoUserProvider.php: It’s an implementation of the authentication provider.
  • app/Services/Auth/JsonGuard.php: It’s an implementation of the authentication guard driver.
  • app/Providers/AuthServiceProvider.php: This is an existing file that we’ll use to add our service container bindings.
  • app/Http/Controllers/MongoController.php: It’s a demo controller file that we’ll implement to test our custom guard.

Don’t worry if the list of the files doesn’t make much sense yet as we’ll discuss everything in detail as we go through it.

In this section, we’ll go through the implementation of the required files.

The first thing that we need to do is to inform Laravel about our custom guard. Go ahead and enter the custom guard details in the config/auth.php file as shown.

As you can see, we’ve added our custom guard under the custom key.

Next, we need to add an associated provider entry in the providers section.

We’ve added our provider entry under the mongo key.

Finally, let’s change the default authentication guard from web to custom.

Of course, it won’t work yet, as we’ve not implemented the necessary files yet. And that’s what we’ll discuss in the next couple of sections.

In this section, we’ll implement the necessary files that talk to the underlying MongoDB instance.

Let’s first create a configuration file config/mongo.php that holds the default MongoDB connection settings.

Of course, you need to change the placeholder values as per your settings.

Instead of directly creating a class that interacts with MongoDB, we’ll create an interface in the first place.

The benefit of creating an interface is that it provides a contract that a developer must adhere to while implementing it. Also, our implementation of MongoDB could be easily swapped with another NoSQL implementation if needed.

Go ahead and create an interface file app/Services/Contracts/NosqlServiceInterface.php with the following contents.

It’s a pretty simple interface that declares the basic CRUD methods that a class must define that implements this interface.

Now, let’s define an actual class at app/Database/MongoDatabase.php.

Of course, I assume that you’ve installed MongoDB and the corresponding MongoDB PHP extension.

The __construct method instantiates the MongoClient class with the necessary parameters. The other important method we’re interested in is the find method, which retrieves the record based on the criteria provided as method arguments.

So that was the implementation of the MongoDB driver, and I tried to keep it as simple as possible.

Adhering to the standards of the authentication system, we need to implement the User model that must implement the Illuminate\Contracts\Auth\Authenticatable contract.

Go ahead and create a file app/Models/Auth/User.php with the following contents.

You should have already noticed that App\Models\Auth\User implements the Illuminate\Contracts\Auth\Authenticatable contract.

Most of the methods implemented in our class are self-explanatory. Having said that, we’ve defined the fetchUserByCredentials method, which retrieves the user from the available back end. In our case, it’ll be a MongoDatabase class that’ll be called to retrieve the necessary information.

So that’s the implementation of the User model.

As we discussed earlier, the Laravel authentication system consists of two elements—guards and providers.

In this section, we’ll create an authentication provider that deals with the user retrieval from the back end.

Go ahead and create a file app/Extensions/MongoUserProvider.php as shown below.

Again, you need to make sure that the custom provider must implement the Illuminate\Contracts\Auth\UserProvider contract.

Moving ahead, it defines two important methods—retrieveByCredentials and validateCredentials.

The retrieveByCredentials method is used to retrieve the user credentials using the User model class that was discussed in the earlier section. On the other hand, the validateCredentials method is used to validate a user against the given set of credentials.

And that was the implementation of our custom authentication provider. In the next section, we’ll go ahead and create a guard that interacts with the MongoUserProvider authentication provider.

As we discussed earlier, the guard in the Laravel authentication system provisions how the user is authenticated. In our case, we’ll check the presence of the jsondata request parameter that should contain the JSON-encoded string of the credentials.

In this section, we’ll create a guard that interacts with the authentication provider that was just created in the last section.

Go ahead and create a file app/Services/Auth/JsonGuard.php with the following contents.

First of all, our class needs to implement the Illuminate\Contracts\Auth\Guardinterface. Thus, we need to define all the methods declared in that interface.

The important thing to note here is that the __construct function requires an implementation of Illuminate\Contracts\Auth\UserProvider. In our case, we’ll pass an instance of App\Extensions\MongoUserProvider, as we’ll see in the later section.

Next, there’s a function getJsonParams that retrieves the user credentials from the request parameter named jsondata. As it’s expected that we’ll receive a JSON encoded string of the user credentials, we’ve used the json_decodefunction to decode the JSON data.

In the validate function, the first thing we check is the existence of the $credentials argument. If it’s not present, we’ll call the getJsonParams method to retrieve user credentials from the request parameters.

Next, we call the retrieveByCredentials method of the MongoUserProviderprovider that retrieves the user from the MongoDB database back end. Finally, it’s the validateCredentials method of the MongoUserProvider provider that checks the validity of the User.

So that was the implementation of our custom guard. The next section describes how to stitch these pieces together to form a successful authentication system.

So far, we’ve developed all the elements of the custom authentication guard that should provide us a new authentication system. However, it won’t work out of the box as we need to register it in the first place using the Laravel service container bindings.

As you should already know, the Laravel service provider is the right place to implement the necessary bindings.

Go ahead and open the file app/Providers/AuthServiceProvider.php that allows us to add authentication service container bindings. If it doesn’t contain any custom changes, you could just replace it with the following contents.

Let’s go through the boot method that contains most of the provider bindings.

To start with, we’ll create bindings for the App\Database\MongoDatabase and App\Models\Auth\User elements.

It’s been a while that we’ve been talking about provider and guard, and it’s time to plug our custom guard into the Laravel authentication system.

We’ve used the provider method of the Auth Facade to add our custom authentication provider under the key mongo. Recall that the key reflects the settings that were added earlier in the auth.php file.

In a similar way, we’ll inject our custom guard implementation using the extend method of the Auth facade.

Next, there’s a register method that we’ve used to bind the App\Services\Contracts\NosqlServiceInterface interface to the App\Database\MongoDatabase implementation.

So whenever there’s a need to resolve the App\Services\Contracts\NosqlServiceInterface dependency, Laravel responds with the implementation of the App\Database\MongoDatabase adapter.

The benefit of using this approach is that one could easily swap the given implementation with a custom implementation. For example, let’s say someone would like to replace the App\Database\MongoDatabaseimplementation with the CouchDB adapter in future. In that case, they just need to add the corresponding binding in the register method.

So that was the service provider at your disposal. At this moment, we have everything that is required to test our custom guard implementation, so the next and concluding section is all about that.

Does It Work?

You’ve done all the hard work setting up your first custom authentication guard, and now it’s time to reap the benefits as we’ll go ahead and give it a try.

Let’s quickly implement a pretty basic controller file app/Http/Controllers/MongoController.php as shown below.

Take a close look at the dependency of the login method, which requires the implementation of the Illuminate\Contracts\Auth\Guard guard. Since we’ve set the custom guard as the default guard in the auth.php file, it’s the App\Services\Auth\JsonGuard that’ll be injected actually!

Next, we’ve called the validate method of the App\Services\Auth\JsonGuardclass, which in turn initiates a series of method calls:

  • It calls the retrieveByCredentials method of the App\Extensions\MongoUserProvider class.
  • The retrieveByCredentials method calls the fetchUserByCredentialsmethod of the User App\Models\Auth\User class.
  • The fetchUserByCredentials method calls the find method of the App\Database\MongoDatabase to retrieve the user credentials.
  • Finally, the find method of the App\Database\MongoDatabase returns the response!

If everything works as expected, we should get an authenticated user by calling the user method of our guard.

To access the controller, you should add an associated route in the routes/web.php file.

Try accessing the URL http://your-laravel-site/custom/mongo/login without passing any parameters and you should see a “not authorized” message.

On the other hand, try something like http://your-laravel-site/custom/mongo/login?jsondata={“username”:”admin”,”password”:”admin”}and that should return a success message if the user is present in your database.

Please note that this is just for example purposes, to demonstrate how the custom guard works. You should implement a foolproof solution for a feature like login. In fact, I’ve just provided an insight into the authentication flow; you’re responsible for building a robust and secure solution for your application.

That ends our journey today, and hopefully I’ll be back with more useful stuff. If you want me to write on any specific topics, don’t forget to drop me a line!

The Laravel framework provides a solid authentication system in the core that could be extended if you want to implement a custom one. That was the topic of today’s article to implement a custom guard and plug it in to the Laravel authentication workflow.

In the course of that, we went ahead and developed a system that authenticates the user based on the JSON payload in the request and matches it with the MongoDB database. And to achieve that, we ended up creating a custom guard and a custom provider implementation.

I hope the exercise has provided you an insight into the Laravel authentication flow, and you should now feel more confident about its inner workings.

For those of you who are either just getting started with Laravel or looking to expand your knowledge, site, or application with extensions, we have a variety of things you can study on Envato Market.

I would love to hear your feedback and suggestions, so shout out loud using the feed below!

Source By : https://bit.ly/2ymfFEe

Author Bio:
Andrew Hanks is working for 9series Solutions as a Digital Marketing Expert. He is passionate about sharing updates on Laravel Development services and PHP Frameworks. Using the latest tools & strategies for marketing is something he loves.

Advertisements

10 Reasons to Begin a Graphic Design Career

If you’re feeling stuck in your current job and looking to make a career change, you’ve come to the right place.

Like you, most of Shillington’s prospective students are considering their next career move. Having always dreamed of a graphic design career, and inspired by our creative approach, these individuals enroll in our program, learn a wide-range of skills, build impressive graphic design portfolios, and graduate in as little as three months with enough knowledge and experience to land a creative career.

If you’re ready to make the switch but would like a little more information about whether a career in design is for you, consider the following 10 reasons to become a graphic designer.

1. Learning will be a daily thing

learning is a daily component of a graphic design career

When you’re a graphic designer, your work will never stop evolving or improving. There will always be new challenges to overcome. New problems to solve. It’s a never-ending whirlwind of discovery and invention. You’ll make mistakes. We all do.

If you’re still not convinced, take inspiration from Paula Scher who eloquently once said: “It’s through mistakes that you actually can grow. You have to get bad in order to get good.”

2. Design will always be in demand

humans are still in demand for graphic design careers

In the age of automation, when we’re constantly being told that our jobs will one day be taken over by robots, you can be rest assured that graphic design will always require human thinking and creativity. It’s an essential cog in the world of work; one that is required for any brand or business.

From simple business cards and printed materials, to packaged goods, websites and advertisements—it’s unstoppable. Visual communication will live on, and it takes a designer to imagine all its possibilities.

3. Design opens up so many different career paths

graphic design career path

You’ll be able to add value to any workplace, not just a design studio. Design is something that no business can live without. If an agency isn’t quite for you, perhaps you might want to venture into editorial design and work for a major publisher? Or join an internal team at one of the world’s biggest sports brands? Your creative career path is open to so many exciting routes.

4. Designing will boost your problem-solving skills

problem solving is a part of your graphic design career

Creativity is crucial for any business. Steve Jobs of Apple once said: “It’s in Apple’s DNA that technology alone is not enough. It’s technology married with the liberal arts, married with the humanities, that yields the results that make our hearts sing.”

It’s for this reason that a graphic design career will enhance your problem-solving skills—not just because you’re overcoming common issues for clients; but because you’re encouraged to consider the bigger picture. What will your design solve? How will it add value? How will it achieve a brand’s goals? Design will boost more skills than you realise.

5. You’ll enjoy working as part of a team

you will enjoy teamwork in a graphic design career

Graphic designers are rarely alone; they’re often part of a creative team or working closely with the client, collaborating to come up with the best possible solution. You’re likely to get to know PR professionals, copywriters, marketers, advertisers… you’ll probably work with senior management and be expected to consult with company directors.

Your role will rely on many business relationships; the knock-on benefits of which will only boost your skills and experience—especially your ability to effectively deal with different personalities.

6. There’s (usually) no need for a suit and tie

graphic design career allows casual dress

Hate stiff white shirts and uncomfortable blazers? Relax. Graphic design is hands on career for creative minds and designers tend to have more relaxed work attire these days. T-shirts, jeans and trainers are practically the uniform. You can’t be creative when your arms struggle to move in a formal business suit. Clients won’t mind either. It’s widely accepted that designers dress a certain way, and that’s alright with us too.

7. Your graphic design career path is unpredictable

a graphic design career can be unpredictable

Think you’re just going to follow the herd? A graphic design career can take you to places you never thought possible. You could secure a job at a studio on the other side of the planet, or find that your employment means lots of travel to far flung places. You might even go solo and launch your own studio someday. The possibilities really are endless.

8. You could see your work in lights

see your name in lights with a graphic design career

How would you feel if you spotted your work on a billboard? Or in a magazine? The sense of job satisfaction can be overwhelming. It’s your creativity up in lights, for everyone to see. Nothing beats the feeling of contributing to something that you know will inspire many people.

9. You’ll change the way you see the world

inspiration is all around with a graphic design career

When you walk down the street as a graphic designer, you’ll see things in a completely new light. It’s because your job will become your life. You’ll find inspiration in everything you see and do, saving ideas for your next project. Design brings a new perspective, and encourages you to get out there and discover new things. From art galleries and architecture to clothing and accessories—your life will be full of creative wonder.

10. You’ll never stop being inspired

with a graphic design career inspiration is all around

Once you’ve mastered something in a job, things can get boring quickly. That’s not necessarily the same for graphic designers. So, whether you’re changing careers at 40 or just getting started at 50, a career in design will always leave you feeling inspired. Trends will develop and change, keeping you well and truly on your toes from one day to the next. You’ll never know what’s around the corner. And for a career choice, that has to be the most inspirational.

Source By : https://bit.ly/2Lbi1bo

Andrew Hanks is Digital Marketing Expert working for 9series Solutions which is well known for Graphic Design Company in India.He believes in responsive website design and user friendly website help to generate lead.

Why MEAN Stack for your next WebApp

In today’s dynamic world, churning out rapid application prototypes with super-flexible design which adapts to volatile specifications is the key business requirement. This necessitates a software stack which gives the required freedom and power to the developer to assume a flexible, locally owned schema, in-built support for end to end testability and harness the ever growing open source repository of re-usable plugins for speedy iterations. MEAN stack has proven to be an attractive choice to fulfil the above requirements.

MEAN (MongoDB, Express, Angular & Node.js) is an open source JavaScript bundle for web-applications consisting of following components which can very well be used independently:

MongoDB – a schema-less (document-oriented) NoSQL database

Express.js – a server-side JavaScript framework running on top of Node.js

Angular – a browser-independent MVC JavaScript UI framework

Node.js – a server-side JavaScript runtime based upon Google’s V8 JavaScript engine

Traditionally, the developer had to learn and master different programming languages for multiple layers.

Just for example, to develop a Java-based application it is necessary to have a good grasp of JavaScript for front-end validation, Java for server-side logic as well as good knowledge of XML and SQL.

With the MEAN stack, the story is completely different.

All you need to know and master is the JavaScript (ECMAScript) language for all the components from the presentation layer (Angular) to the database (MongoDB). \

With such an isomorphic programming style, not only there are significant productivity gains but better performance as well since the data transfer among the application layers takes place in the form of JSON (JavaScript Object Notation) format.

This greatly reduces the usual overhead and complexity associated with conversion between HTTP, JavaScript, Java, XML and SQL as the data flows between the layers in either directions.

Advantages of using MEAN Stack :
Large pool of JavaScript developers:
Java developers have always been at a premium for enterprise development. With the Web revolution, there was a large untapped pool of JavaScript developers out there to be leveraged for full-fledged Enterprise application development.

Young developers love the inherent freedom and flexibility of JavaScript (no compilation, no type declarations and no restrictive Object oriented programming principles to master before jumping in to write any code!) which meant a lower barrier to entry for new developers.

Declarative UX and testability: Over the last few years, Angular emerged as a clear winner among the plethora of confusing JavaScript UI libraries with its promise of code-less browser-independence, natural blending with HTML to adapt it for application development, two-way binding and finally, a clean separation of presentation from UI logic.

To tame the uber-flexible dynamic language and bring predictability to the output, open source BDD-style unit testing tools like Jasmine, task runners like Karma came handy.

Cloud-hosted continuous-integration services like CircleCI make life easier.

Easier debugging and code-reuse: When you have a single language to work with across layers, it becomes easier to trace the execution thread, watch how the data gets manipulated and debug the flow with a consistent set of free open-source tools.

Libraries developed once can be seamlessly reused for front-end as well as back-end resulting in significant boost to productivity. The thriving npm.js repository for every imaginable task in hand is the proof of the pudding.

Scalability: Node.js’s underlying V8 JavaScript engine by Google is known to utilize server resources efficiently due to its non-conventional single-threaded execution model, which is a notable departure from the classic Java (and C#.NET) multi-threaded way of handling concurrent execution, synchronization, locks etc.

Node.js provides testable concurrency without the headaches and uncertainty of multi-threading/cron jobs. First, the I/O based event loop architecture and C++ core modules deal with thousands of requests with ultra-frugal utilization of CPU and memory unlike a JVM.

In addition to that, the dynamic load can be handled by leveraging the Cloud’s natural horizontal elastic scaling capability by launching additional instances on the fly. Finally, MongoDB’s cloud-ready replication and sharding features boost the performance with great availability.

Variations of the MEAN Stack
Since the term MEAN was first coined by Valeri Karpov (a MongoDB engineer) in 2013, it has gained significant popularity in Enterprise world for serious business application development.

However, after the initial excitement established the concept that such a new combination can finally give a serious competition to the Java based well-established behemoths, it was natural that developers and organizations began customizing the stack make-your-pizza style as they preferred different components for various layers in the originally proposed MEAN stack such as,

1. MERN – Replacing Angular with React.js

While Angular.js was great framework of its kind, it had a steep learning curve, lacked good support for mobile web apps.

Google – the creators of Angular.js, fixed these issues to a great extent with an all-new 2.0 version named just Angular (latest stable is 4.0 at the time of this writing).

Facebook in the meantime released its JavaScript library called React.js which is not a full-fledged framework, allowed the flexibility to mix-and-match third party libraries like Backbone.js and promoted an event-driven “reactive” style of programming and a virtual server-side DOM (Document Object Model).

Since then, Angular has tried to keep up the race with improvement over the original design but the MERN stack has now grown as an interesting alternative.

2. MHAN – Replacing Express.js with Hapi.js

While Express.js is a good lightweight framework handling client-requests efficiently providing good performance rivalled only by raw-http processing, it still has some limitations, which can be a concern for Enterprise-grade projects.

For this reason, Walmart Labs developed another open-source alternative called Hapi.js which provides some features like better error handling, modularity, clean separation of configuration from request handling, great plugin system, built-in support for popular authentication/authorization schemes and greater abstraction from the http model.

Future of traditional stacks (Java, .NET, Python, Groovy and LAMP)

The MEAN stack (and its variations mentioned above) is set to give a tough fight to the traditional Java/.NET stacks when it comes to creating fresh apps with their own schemas.

The old stacks are here to stay for a long time due to years of investment and working functionality that nobody wants to rewrite in a flexible new language.

Also, extending the functionality in those projects is still a big task which is best handled in the same language. That’s why we see a sudden rise in popularity of Java-based micro-services stacks such as SpringBoot from Pivotal.

However, the same can’t be spoken about other competing stacks like Python (with Django, Flask etc). It may continue to exist but may not take over the game completely beyond their niche, simply because there is no competition to JavaScript in the browser, which gives the MEAN stack an unfair advantage over beautifully simple and powerful server-side languages like Python/Groovy and even Scala.

What happens to LAMP Stack

The hugely popular LAMP (Linux, Apache, MySql, PHP) stack which is often compared with MEAN isn’t likely to get the lime-light once again.

While Linux will continue to thrive, no doubt as an OS, developers are going away from MySql since the takeover by Oracle. There is a trend of migration to MariaDB (open-source community fork of MySQL) or PostgresSQL.

PHP never was a clean way to separate UI from logic and the long-time king of web-server – the Apache Httpd is getting serious competition from the likes of LiteSpeed and Nginx when it comes to ease of configuration and performance.

Overall, while LAMP web applications will continue to be maintained for quite some time, for new projects it seems it may not be the attractive choice any longer as highlighted in recent InfoWorld article with detailed reasoning.

Conclusion:

MEAN is likely to stay here as a popular full-stack development option, especially for spinning out quick, loosely coupled web apps and ReST (Representational State Transfer) based API services.

However, it was built with the assumption of availability of abundant good quality JavaScript developers. Though it largely holds true for open-source community.

Adopting such as stack is still awkward for existing Enterprise application developers who are still in deep love with their Java/.NET world of pure OOPs paradigms. But Microsoft has come to rescue with a familiar “OOP simulating” TypeScript language (a typed superset of JavaScript that “trans-piles” to plain JavaScript), it still pays to be good at pure JavaScript (ES6) and get comfortable with its features. Organizations who invest in reskilling the old developers for acquiring strong JavaScript skills will surely reap the benefits in near future.

About Author:
Andrew Hanks is working for 9series Solutions as a Digital Marketing Expert. He is passionate about sharing updates on MEAN Development services and JS (JavaScript).

Laravel – The Best Open Source PHP Based Web App Development Framework

Laravel development is one of the best open-source PHP based web app frameworks and is sharper and endowed with MVC architectural pattern. Laravel has been identified as one of the best frameworks that are being preferred for the development of high-quality websites and trending web applications. This framework is appropriate for developing high performing and creative web apps to meet the customized business requirements.

Laravel - The Best Open Source PHP Based Web App Development Framework

Each of our best Laravel developers are well-acquainted with all the aspects of the Laravel framework, thus making our services simply perfect for you.

Our top Laravel development team works to ensure every application are completely tested and well-built to fulfill your needs. We specialize in creating custom web apps that are reliable & maintainable.

Swift 4 – A Step Ahead to The Most Advanced Programming Language – iOS Development

Hey, welcome back!!! Let’s move one step ahead with the open source development language from Swift 3 to Swift 4. We, at 9series, have filtered out points of our next strides in developing mobile apps using Swift 4.

Swift 4

Swift 4 is the latest major release for iOS App Developer that is intended to be completed in the fall of 2017. Its main focus is to provide source compatibility with Swift 3 code while implementing essential feature work that needs to achieve binary stability in the language. It will contain valuable enhancements to the core language and Standard Library, particularly in the generics system and an overhaul of the String type.

Source Compatibility Modes

The Swift 4 compiler will provide two language modes: Swift version 3 and Swift version 4. Swift 3 established the language for source-level stability and now Swift 4 releases source compatibility as a feature moving ahead.

    • Swift 3 mode is default for existing code and will build source code that works with the Swift 3 compiler
    • Swift 4 mode allows you to use new features and performance optimizations of Swift 4, some of which may require migration
    • Mixed mode allows you to take advantage of interoperability between binaries built with the same compiler. The proposed design is that a project containing various Swift modules, such as a Xcode project with multiple Swift targets, will be able to ratify into the specific Swift language mode on per module (target) level and that they can smoothly interact within the same compiled binary.

New Features in Swift 4

    • Swift 4 presents another codable protocol that gives a chance to serialize and deserialize custom data types without composing any special code – and without worrying about losing your value types
    • Quicker and simpler to use strings that retain Unicode correctness and add support for using, creating and managing substrings
    • Smart key paths for type-safe, effective and extensible key value coding for Swift types
    • Enhancements to create and manipulate Dictionary and Set types

Swift has many other features to make your code more expressive:

Multi-Line String Literals

To start a string literal, you need to write three double quotation marks: “”” then press return. After pressing return key, start writing strings with any variables, line breaks and double quotes. To end multi line string literal again write ””” in new line. Ex:-

1

Strings are Collections

Just like in earlier version of Swift, Strings can be handled as a collection. No need to writestring.characters.something to perform string manipulation.

2

Dictionary Functionality has Improved

Swift 4 combines some additional functionality to dictionaries to make them more strong, and also to make them work more like you would expect. Let’s start with a simple example: Modifying dictionaries in Swift 3 does not return a new dictionary. Instead, it returns an array of tuples with key/value labels.

3

After that code runs you can’t read distinction[“Maths”] because it is no longer a dictionary. Instead, you need to use distinction[0].value, which is not good for us because we apply filter on dictionary and we got an array.

As of Swift 4, this acts more like you would expect: you get back a latest dictionary. Obviously this will break any existing code that relies on the array return type.

Similarly, the map() method on dictionaries got a key-value tuple passed in, and could return a single value to be added to an array.

4

That has not changed in Swift 4, but there is a new method called mapValues(). It allows you to modify the values and place them back into a dictionary using the original keys.

Here we try to form different buckets where each bucket will contain values having same first character in their name. For Example:-.

5

It’s now likely to obtain a dictionary key and provide a default value to use if the key is missing. In following statement if there is no value for key “Bio” found then it will print default value.

6

Built in Encoding and Decoding

Swift 4 appears with built-in encoders and decoders for JSON. JSON to Model conversion comes in built in.

7

One Sided Range

Swift 4 introduces Python-like one-sided collection slicing, where the missing side is automatically assumed to be the start or end of the collection.

8

Conclusion

Like with other Swift releases, 4.0 was announced at WWDC ’17 and released in beta form for developers alongside Xcode 9. This release of Swift added quite a few refinements and features to the programming language. First release of Swift 4.0 will bring overall stability to the source and binary interface, or ABI.

Keynotes – Apple’s Announcements at WWDC 2017 – iOS Application Developers

The 2017 Worldwide Developers Conference keynote was Apple’s biggest event in years, with the company introducing both new software platforms and a range of new hardware products.

apple developers wwdc2017

As usual, the event began with the message for developers “Keep making apps, the world is depending on you”.

And as always, the event started with a keynote during which Apple announced dates (June 5–9, 2017 in San Jose) of updates for their iOS, OS X, watchOS, and tvOS platforms.

iOS 11

A Giant step for iPhone, A Monumental leap for iPad

Apple officially announced iOS 11 at WWDC 2017. The next major update to the operating system running on millions of iPhones and iPads will improve.

Messages App Syncs Across Multiple Devices

The first new iOS 11 feature: synchronized conversations across iCloud, iOS, and macOS. Messages are moving to iCloud.

If you erase a message on your iPhone or iPad, then it will also delete from the iPad and the Mac and vice-versa. Our conversations will be stored on iCloud, which will make them easier to retrieve your future Apple devices.

Apple Pay

There is also an update related to Apple Pay, which will now be able to pay people. Person-to-person payments let people pay directly from Messages as an iMessage app.

It uses the TouchID fingerprint sensor. And the money which received will go into your Apple Pay Cash Card, which you can use for further Apple Pay payments, or to transfer money back into your account.

It might be helpful to make payment through application and person can directly transfer money to his friends or family members or use as general. Hence, we can enhance our application to the next level in terms of eCommerce market.

SIRI

Aha, Apple has made improvements to Siri that makes assistant’s voice sound more natural when responding to users. Siri will now be able to perform translations from English to Chinese, French, German, Italian, or Spanish. Wow…

As a ios developers, we can definitely use this feature into multi-language application and give better user-interface as well as performance to our app users.

Siri is also getting smarter about suggestions. On-device, learning is synced across other Apple devices but kept completely private, readable only for you. Siri gives suggestions based on personal usage of Safari, News, Mail, Messages and more. For example, as Siri learns topics or places, a user is interested in while browsing Safari.

Camera

The camera also has lots of improvements, including improved image quality. Portrait Mode in the iPhone 7 Plus can be taken with Optical Image Stabilisation, True Tone flash and HDR.

Apple has also added a new technology called High Efficiency Image File Format (HEIF) that reduces the file size of your iPhone 7 or 7 Plus photos.

This can be helpful into the application where Image and its quality is considered as the core concept.

CONTROL CENTER

In iOS 11, Apple has redesigned Control Center, which is the thing that users can swipe up to access frequent and important settings or change songs when listening to music.

Drag And Drop For IPAD

Apple is specially focusing on productivity for the iPad with iOS 11.

A new drag-and-drop feature lets you quickly move info or media from one split-screen app into the other besides it. Drag and drop can also be used with apps on your dock or home screen.

Lock Screen Improvement

The Lock Screen in iOS 11 has been improved so that you can see all of your Notifications in one place.

You can see all of your Notifications, simply pull it down from the top of the screen. Then you will be able to see both your recent and missed notifications in one place.

Here, we should take care about sending an extra unnecessary notifications, as our users can’t get bored from such things. And only useful notifications should be seen to attract the user of our application.

Maps App

Apple announced that the Maps app in iOS 11 will support indoor mall and airport maps. The indoor maps will allow you to see which restaurants are past security at the airport. And you can also see which stores are on what levels in the malls.

Lane Guidance in Maps now encourages you to dodge missing a turn or an exit by showing which lane you should be in when you’re navigating. You can also check the speed limit of the road.

As a mobile app developer, we should think that whether this feature can put our application into an advanced level in terms of event organization kind of feature where our users can easily find the place/stall where he needs to go.

Do Not Disturb While Driving

Apple iOS 11 has a very useful safety called Do Not Disturb while Driving. This feature helps drivers stay focused on the road by automatically silencing notifications. And you can send auto-replies to your contacts in your favorites so that they know you are driving.

App Store App Improvements: A whole new design, A whole new perspective

The App Store has been redesigned from the ground to help you discover new apps and games you can’t live without. You’ll see daily stories by experts, a dedicated Games tab, lists for all kinds of apps, and much more. It’s the biggest thing to come to the App Store since apps. And now apps that are submitted to the Apple App Store are generally reviewed within 24 hours.

ARKIT

Apple is building augmented reality directly into the core of iOS, giving developers the tools they need to convincingly blend digital entertainment with the real world. So with help of this new framework, we can effectively introduce augmented reality into our application.

Now, it’s like behind-the-scenes stuff for iOS. It’s getting Metal 2, of course, and a new set of machine learning APIs letting developers use Apple’s natural language comprehension and facial recognition tools.

macOS High Sierra

Your Mac. Elevated

macOS High Sierra introduces new core technologies that improve the most important functions of your Mac. From re-architecting, it shows how it stores your data & how you watch videos to unleash the full power of the graphics processors.

Apple File System

To your Mac, everything you care about is data. And a file system is what organizes all that data into files and folders you can access with a click. Apple’s current file system was designed in the early days of Mac, and it has performed beautifully ever since. But today’s flash‑based Mac opens up new possibilities for innovation, so it’s time to lay a new foundation. With macOS High Sierra, Apple is introducing the Apple File System to Mac, with an advanced architecture that brings a new level of security and responsiveness.

Below are some bullet points about updates in macOS High Sierra:

    • Modifies Safari by including autoplay video blocking
    • Intelligent tracking prevention to prevent ad trackers
    • Better Photos editing and organization
    • A faster and new behind-the-scenes file system
    • A stronger updated graphics engine that supports VR development
    • Support for the Unity and Unreal gaming engines
    • Using HEVC, video stream better and take up less space on your Mac, while preserving the same visual quality
    • Now Metal 2 not only takes the visual experience to the next level, but also adds capabilities like machine learning, virtual reality, and external GPU support for entertainment and professional creative apps.
    • Virtual reality for Mac. It’s a whole new world.

watchOS 4

More intuitive, More intelligent, More you

Apple announced a new version of watchOS. One of the most noticeable changes in watchOS 4 is the option of using a Siri watch face. This automatically displays contextual information on the Apple Watch, such as approaching appointments, and traffic reports if the wearer is going to work.

New fitness feature includes in controls, more prompts to set goals, and two-way workout data exchange with certain gym equipment. The Apple Watch will also be able to better connect with other hardware gadgets, such as continuous glucose monitors and smart tennis rackets, via NFC. This can be a useful feature where our application also interact with Watch OS.

watchOS 4 also includes a new Music app meant to improve the AirPods experience. Multiple playlists can now be synced including Apple Music-recommended playlists.

The Dock on watchOS 4 has a new look with a vertically scrolling interface with can lead to the UI Interface of the watch application. watchOS 4 can also automatically start when workouts are started, and music playback controls are integrated with the Workout app.

Control Center gains a new flashlight function using the display which also works during outdoor, night workouts as a safety feature.

tvOS

In WWDC 2017, one thing to say from apple about tvOS, The Apple TV is getting a big new content, as Amazon Prime Video is coming to Apple TV and Apple’s new TV app.

New Macs and the iMac Pro

Now faster across the line

Apple also upgraded its MacBook and MacBook Pro lineup with faster processors and SSDs. It also refreshed the MacBooks.

Apple’s 13-inch MacBook Pro without the Touch Bar on top now comes with Intel core i5 processor clocked at 2.3GHz, 128GB Storage and 8GB RAM. This also has two Thunderbolts 3.0 ports.

iMac Pro: The most powerful Mac ever

The all-new iMac Pro, with its gorgeous 27-inch Retina 5K display, up to 18-core Xeon processors and up to 22 Teraflops of graphics computation, is the most powerful Mac ever made. iMac Pro packs incredible performance for advanced graphics editing, virtual reality content creation and real-time 3D rendering.

iPad Pro

Any you can do, you can do better

The new version of the iPad Pro has a 10.5-inch display, 20 percent larger than the previous 9.7-inch model. Apple said that It features a better display with richer color and a new feature called ProMotion, which updates its content up to 120 times per second making it feel smoother and more responsive.

HomePod: Apple’s new Siri speaker

The HomePod has seven tweeters and four-inch woofer; it has an A8 chip living inside it. That’s a feature Sonos has too, letting the speakers adjust their output to, say, push the vocals down the centre of the room while bouncing the bass off the wall.

A feature will respond to “Hey, Siri,” play from your Apple Music account, and answer questions about the music it’s playing. It will also handle other Siri queries, such as weather, news, messages, podcasts, stocks, controlling smart home devices via HomeKit, etc.

Conclusion

Above are the announced points of Apple during WWDC 2017. Though we haven’t had a chance to look through everything yet, feel free to post any missing points or share your thoughts about these new features in iOS app development.

Implement Routing using Nodejs

Nodejs developers, we hope that you have gone through our last blog about Node.js and their kinds of purposes.

Node js developers

Today we will share something essential about routing in node js. Node is a cross-platform technology. Routing is core heart of any web programming language. In older days we were performing routing by lazy techniques by passing parameters using “?“ and simple post. But now as technology has grown up, routing becomes smarter.

In node, we can perform routing by many ways. But today we are going to lead on express only. You can also achieve routing by URL or other packages.

Now, give us a chance to give you a brief introduction about how node is getting worked by creating a simple host (a node server and request to the node for HTTP) as this is the basic part of doing routing.

For this, we require having npm installed on our machine.

What is Require?

Require is something that includes in language c and requires in PHP. Node is nothing but a collection of different packages which are created by javascript folks and usage in best open source PHP developers framework. For package installation, we are using npm.

Achieve Routing Using Express

1) Setup Server using Node

2) Install Express Package

3) Create Routing and use Express

1. Setup Server

nodejs code1

nodejs code2

2. Install Express Package

a. $ npm install express

3. Use of Express in Routing

I have set simple “Hello”

nodejs code3

This was an example of GET, you can also use POST, DELETE, PUT

nodejs code4

First, we have to create a server where we have set port and make a listener for HTTP on that port. Now in the browser when you hit http://localhost:8081 we will require a package express and create app instance, that app instance will handle our application request and our code will work like micro framework like slim and lumen.

At 9series, We are working with node.js for routing in node using modules like URL, express and path. We are providing the solution with front-end and back-end solution using laravel, node, vue and angular, etc.

MongoDB Developers Boilerplate Overview

The entire software development industry has seen a radical turn in the past decade. As businesses move online, the demand for responsive web applications has reached a new herald. To meet this need, we at 9series constantly strive and learn and keep ourselves abreast with latest industry developments to deliver the best to our customers.

Database is a vital angle to creating proficient web applications. Customary methods for database improvement and administration don’t toll achievement in today’s dynamic advanced environment. A crisp approach is required.Best MongoDB Developers in India precisely conveys this esteem to the table. we give master MongoDB advancement administrations to our clients.
mongodb-developers-boilerplate-overview

What is MongoDB?

MongoDB is an open source database system. Developed and supported by 10gen, it is the most popular NoSQL database management system. MongoDB is document oriented, based on NoSQL and supports document management, modification, and real-time processing and analysis on a large scale basis. Today, MongoDB is used by well-known brands like eBay, MetLife, Telefónica, Foursquare, MTV Networks and the UK Government.

Where it works?

MongoDB is the go-to solution for platforms where large volumes of data are required to process high performance. MongoDB is good at handling complex and heterogeneous data to model in a relational schema and perform real-time analytics.

MongoDB is particularly well suited for the following:

  • Big Data Analytics, High Traffic Apps
  • Social Network Applications
  • Event Logging Application
  • Content Management Systems
  • E-Commerce Applications
  • Gaming Applications
  • Real-time Analytics
  • High Volume Problems
  • Document Management Systems
  • Mobile Applications
  • Website Operational Data Store
  • Document Oriented Systems

Salient features of MongoDB

  • Scalable: MongoDB presents a scalable platform by enabling addition of replicas which in turn adds read capacity. It also supports management of database as it expands with content and visitors.
  • Consistent across platforms: MongoDB code is centralised and hence, provides a consistent experience across platforms.
  • Easy to search: With MongoDB query language and indexing support, users can perform search, sort, and filtering functions from diverse formats of content easily
  • Fast Performance and Update: MongoDB powers addition of user created content, tags, and comments to the database immediately in a matter of minutes

How E-learning Software Development Innovates Education Industry

E-learning industry has proven to be one of the rapid growing industries. There have been a lot of contributions by businesses right from content display to teaching online, online exams, training solutions, interactive solutions, etc. Nowadays e-learning solutions have replaced the stringent and tough methodologies which were used to impart education to students.
Tools of e-learning development encourage people to create quality online courses which are visually appealing and at the same time render appropriate and engaging content. There is a broad range of tools that address certain areas of content authoring, instructional design, and even course delivery. All of these technologies are great, however, it all depends on how people manage and combine them.

E-learning software development company has created huge opportunities for well-known Colleges, Universities and Institutes handing over online certification and e-learning programs, learning on the internet have become familiar among students, professionals, and corporates. In order to meet this mounting demand, organizations are now concentrating on delivering e-learning applications & solutions to their students and customers. 

Cloud computing is the advanced platform which everybody is looking for. Storing data, applications, software in a server apart from the users have its positive and vital influence on the overall computing concept. Various industries have taken into consideration of the practical apps which can benefit from the technology and so they implemented it on their own systems through websites. One sector of society that could utilize undoubtedly is education. Already companies are using clouds for training employees. Cloud computing could have profitable results in the field of electronic learning, specifically, e-learning online.

It is said that technology brings more controversy and complexity than benefits to classrooms. With the use of tools, those students already have an expertise over it. The era of technology has multiple benefits that will serve to overcome the difficulties of initial integration in the long run. Along with the help of education technology, educators can convey a further level of interest towards education and help to properly integrate students with the learning method. There are sky limits to what education technology can do. There are many companies providing services of E-learning mobile application development companies in India

We 9series deliver complete e-learning application development solutions and portal that shapes your requirements to achieve your goal. We focus on developing and design custom e-learning portal that suits your business model with intensifying user experience. Our completely integrated e-learning services cater secure access to the data and information. Feel free to Contact Us.

The Moving Phase of Android App Development

Smartphones and mobile applications have been conglomerated within our life in such a way, that our young folks cannot even go out from home without these things. With millions of users and enormous amounts of downloads, android Applications are creating a tremendous buzz in the market. From the very initial stage, android app development has experienced an avalanche of applications which are submitted in the Google Play Store so that users can utilize these applications according to their taste and necessity.

The Moving Phase of Android App Development

According to the survey, day by day the demand for smartphones are expanding and businesses are trying to explore their wings by using these smartphone and tablets applications. Millions of software programmers and developers over the globe have accepted that android is the most preferable and suitable platform because of its open source development feature that can be easily accessible from anywhere without investing any amount. This is the reason android applications are sold at an extremely economical rate to its customers while some are even accessible with the expectation of complementary so that customers can easily get enticed by these apps. This is only possible because nowadays more android developers are embracing this operating system. Motivated by this rising demand, Android app development company in India are tempting android app developers with good packages so that they can join their existing team.

With the help of android applications, enterprises and business are trying to establish their presence across the world and want to grab more customer’s attention so that they can gain maximum advantages and be able to make substantial benefits. Below are mentioned some prime reasons why android applications are preferred by the entrepreneurs these days.

  • All android applications are stored in Google Play store which is as of now the largest mobile app market and the cardinal host for android application. Daily, millions of customers are visiting Google Play Store for android applications which are the key reason behind the achievement of the android applications.
  • Most of the android apps are non-chargeable that means android fans are less tolerant towards paying for apps.
  • The hassle-free development offered by Google is another pivotal reason for the success and the popularity of the android apps over the others.
  • For android, Google overhauls all applications and this is another essential reason why android has expanded in the recent period. Hence, entrepreneurs and business owners want to create healthy business strategies for the promotion of their businesses by using android applications.

We are one of the top-notch android app development company in India that has developed successfully multiple android apps.

Want to plan for mobile application development by utilizing modern technologies, then get in touch with us. Our professional team has enough skill and knowledge in android app development. Our android app developers have developed outstanding apps in the field of education and many other assorted fields.