Laravel and Angular(JS), where to start with Angular? - javascript

I'm a software engineer and want to learn developing web applications with PHP and JavaScript. I'm familliar with C#, object oriented programming and working with frameworks.
So i decided to learn directly creating an web application based on a framework (Laravel, as we work with this framework on my work also). I start understanding how the framework works and as programming is not new for me i also understand the basics of PHP.
For the front-end i want to use Angular JS as i heard a lot of positive things about it. During my research on Google about Angular and Angular in combination with Laravel i read that we already have Angular V2 and V4.
I have a few questions about this:
What is the best version to start with? This because i heared the
good things about V1 (and the combi with Laravel), but V2 and V4 has
a complete other concept? I'm a bit confused if it has the same
purpose and if it is still a good approach to combine the newer
versions with Laravel?
I can find how to combine Laravel with AngularJS(1) and how to structure the project, but cant find a good tutorial or explaination how to combine/structure Laravel with
Angular 2 or 4. This also confuses me.... Are the newer versions not
a good combination with Laravel anymore?, Angular just uses Json
API's so why not? or are i'm wrong.
What i found about Laravel and the newer Angular versions is that it is a no-go to use both in 1 project. The advice is to use 2
different projects? I do not understand why as i can still make them
independed from eachtoher in 1 project by a nice folder structure.
So if this is true, what is the reason behind?
If it is no problem to combine both in 1 project, i prefer to do this. But what is the best practice to add Angular into the Laravel project? especially for the folder structure? Is there a tutorial which describes how to use these 2 frameworks in 1 project?
I hope that someone can give me a "kickstart" how to start with increasing my skills.

I would suggest using Vue.js instead if you are familiar with new Laravel 5.x. It is supported by default and plays together pretty good.
https://learninglaravel.net/topics/vuejs
In my previous projects I used Laravel 3/4 + Backbone.js. Backbone, to me, is much better then diving into a full framework that your entire structure ( html + js ) depends on multiple custom tags etc. Backbone gives you a better approach on that case that you can use it partially in some modules etc or you can build your entire layout with it.

Related

Laravel and surveyjs

I'm relatively comfortable with laravel, but know very very little about javascript and npm in general... just to set some context.
I am building an app where I now require a "library of forms" to be filled out. So I'm thinking that I should leverage the expertise of others, and take advantage of what appears to be quite an impressive bit of work, in the form of SurveyJS. https://surveyjs.io/Documentation/Library
I'm probably making a total dog's breakfast of these different concepts, so bear with me please.
So whilst I've got the npm thing running smoothly, I'm not sure I understand the whole webpack compilation thing (yet).
Can you explain to me...
My plan is to have a number of "surveys" defined suitably for the surveyjs "engine". The logic I'm seeing is laravel app eventually pulls "a survey" and passes it to a view to be "executed".
The surveyJs librarys will use that model amd provide the results back to the laravel app - I'll pickup the results in a controller and deal with them.
If this is a suitable approach, then what are these choices about? https://github.com/surveyjs
If I take https://github.com/surveyjs/surveyjs-php (because it's the closest thing I can find to php/laravel then first step is to install docker. I'm a little confused about why I would be installing more "infrastructure" when I'm actually looking for the libraries necessary.
I don't understand why what I'm thinking as a very clever bit of javascript seems to want it's own "infrastructure" - docker / webpacks / etc. And then there's still the whole laravel mix thing.
Thanks in advance.
The main repo has dists for several different js frameworks, the editor repo is just that - only the core surveyjs lib - and the other repos are sample apps, a base project template and extras you may not need.
JavaScript has become a whole ecosystem in and of itself: building with rollup, webpack, parcel, brunch, gulp? For which framework, if any, Angular, react, vue, jquery, vanilla or a little bit of a and a little of b? What are you targeting, browsers, node, both, making an electron app? Using es6? Newer? Typescript?
Basically you're seeing surveyjs want infrastructure because they have answered the above questions. Welcome to javascript :)

Best framework to multi-window app using electron.js

I wrote electron.js multi-window application using native javascript. I want to rewrite this app using one of javascript framework like React, Vue or Angular. They are SPA frameworks so I predict, that one instance corresponds to one window. I think that Angular may be too large for smaller windows.
My app currently has one main window (that executes a lot of code) and three smaller, so I don't want to use too big frameworks for them. One more question: all of those framewoks are compatybile with typescript?
I have built a multi-window (multi-page) Electron app using both Bootstrap and Angular and had no issues.
You can get Typescript definitions for React / Bootstrap here or (for Bootstrap) here.
A tutorial for using Typescript with Angular can be found here. It is a little dated but should be a good starting point.
This question in stackoverflow also has some useful information that you may find helpful.

Recommendations for a web application with Laravel

Im creating a web application with PHP (Laravel 5.) and currently AngularJS (1.). There are some components of the website that i want to build with Angular. For example a Form Generator. A user can click buttons and define which kind of field he/she would like to create. After that, the user can implement it on his website and receive submissions on it. This can be a small app build with Angular.
Currently Angular 2 is a R.C. version, which can be released soon. To keep myself triggered with the newest techniques, i started to explore it a bit and noticed the TypeScript with compiler which runs behind the public(_html) of a application.
Lets split my application in URLs to make my question simpler:
www.domain.com/form-generator -> Uses the script: /angular/form-generator/mainModule.js
www.domain.com/easy-importer -> Uses the script: /angular/easy-importer/mainModule.js
www.domain.com/my-other-small-app-> Uses the script: /angular/my-other-small-app/mainModule.js
Is it possible, efficient and recommendable to create small modules/apps that are loaded on base of the application i build instead of loading them all together? Is Angular 2 recommendable for this or should i consider jQuery and keep Angular 1.*?
If you're looking for a front-end framework to use with Laravel, I reccomend vue.js. Taylor Otwell, the creator of Laravel, has indicated that vue.js is his front-end framework of choice.
Keep in mind, you can use any front-end framework you want. Research what's out there and pick based on your needs. Laravel is not tied to any single front-end: it's your decision.
I only suggest vue.js because it's been adopted by a significant portion of the Laravel community. That community can help you out when you get stuck, and have resources to help you get started. Personally, I watched the Laracasts by Jeffrey Way to get up to speed.

Is Google's Polymer a fully functioning Frontend Framework to Subsitute OR Complement other Frontend Frameworks?

The question is in regard to AngularJS, BackboneJS, EmberJS and the other frameworks.
I have to translate a project from php to javascript and I have to decide, if I am going to use:
AngularJS
Polymer
A combination of them
I prefer using Polymer, because I like it.
Yet, I am missing (and correct me where I am wrong) the ability to make:
Views and link between them (like in Angualar)
Controllers
I know that the structure is up to me, on how to build my application, but it seems that angularjs has a well predefined structure for building mvc-applications.
Therefore I want to know: Is Polymer a substitute for Angular, if you want to build a well structured web application or is Polymer complementary library to be used along other existing frameworks?
EDIT 21.09.2014
No one really answered the question to my fullest satisfaction, therefore I marked it as not answered yet. Many say it just "DEPENDS". But no one is able to elaborate, on what exactly it depends.
On the complexity of the application? On the needs of the application? For what needs does Polymer fit and for which doesn't it fit? These are the answers I was looking for.
Some say it can be used as a frontend framework. Others say that is just a library and others say "Yes and No". Unfortunately rather confusing answers.
I wish there was an official answer to this, but I let you in on what my feeling is. I believe it is a substitute, but Polymer hasn't yet reached the structure, that other frameworks require to work. Maybe this is intentional, maybe it is just a matter of unreached maturity, because the framework is new.
I hope that the creators will explain, when it is best to use AngularJS and when should someone use Polymer for building large scalable web applications.
EDIT 15.08.2015
Polymer 1.0 is out. And it turns out Polymer is officially NOT a framework and is supposed to work in a complentary way with other frontend frameworks.
https://youtu.be/fD2As5RmM8Q?t=6m42s
IMHO both are two different things and they both are to serve two different purposes. Though they have some common features to offer, data-binding can be one of them.
Polymer
If you truly want to use the Awesome Webcomponents, Polymer is one way to achieve that. There are other options like you can go with your vanilla JS, or use other libraries like X-Tag from Mozilla or Bosonic. These libraries polyfill the webcomponent features which are still in drafted state. So, these libs help us have/provide the same user experience across browsers even where there is no native support for the webcomponents.
Angular
This is a full fledged MVC framework. And people here know what Angular as an MVC framework includes/provides.
That all said to answer your question
Google's Polymer is not exactly a fully functioning Frontend Framework and can be used as a Subsitute OR Complement to other Frontend Frameworks. It can be used as a substitution for the V part in Angular as MVC. Like people use React as V in different frameworks. It is not much a different case for me. Being more specific in case of Angular, Polymer is like directives in Angular 1.x while like components in upcoming Angular 2.x.
References
To be more sure of what I am talking about and for additional sources on how to use the Polymer with Angular2 (Angular2 not released to this date)
you can check this video at "https://youtu.be/7WgEuNZCCHk?t=32m15s" starting from time 32:15 where Rob explains how to use the generic webcomponents/polymer as the components/View in the Angular2.
you can check this project "https://github.com/rkirov/youtube-app" which uses Angular2 and google-youtube web component.
https://github.com/ebidel/polymer-experiments/tree/master/polymer-and-angular/together
From the polymer-starter-kit
Framework-free, or framework-compatible
Build your app out of elements, or wire in an external framework to handle business logic. It's up to you!
So, in my view these two projects are not competing each other.
Webcomponent Specs
The webcomponent specs are here for one's reference
Custom Elements - http://w3c.github.io/webcomponents/spec/custom/
HTML Imports - http://w3c.github.io/webcomponents/spec/imports/
Shadow DOM - http://w3c.github.io/webcomponents/spec/shadow/
I just wish the webcomponents are native to the evergreen browsers ASAP.
From the Polymer Starter Kit:
"Framework-free, or framework-compatible
Build your app out of elements, or wire in an external framework to handle business logic. It's up to you!"
Update:
What was described as Carbon Elements seems to fall under:
Polymer(version 2) App Toolbox
Component-based architecture using Polymer and web components.
Responsive design using the app layout components.
Modular routing using the elements.
Localization with <app-localize-behavior>.
Turnkey support for local storage with app storage elements.
Offline caching as a progressive enhancement, using service workers.
Build tooling to support serving your app multiple ways: unbundled for delivery over HTTP/2 with server push, and bundled for delivery over HTTP/1.
Carbon Elements adding framework features
During The Polymer Summit 2015 Keynote, Google announced a new "Polymer idiomatic and framework oriented" set of elements, tentatively named the Carbon elements.
Some quotes from the longer tjsavage answer regarding Angular 2 vs Polymer Carbon:
"The trick is in thinking about the web platform as an application framework... Polymer the library is to the web components component model as the carbon elements will be to using the web platform itself as an application framework: the opinionated rails to make it easier to understand and achieve."
"Angular 2 will provide one way of structuring your application that uses Angular's view of what makes a good application structure. The carbon elements will provide a different way of structuring your application that more directly uses what the web platform itself provides as its structural underpinning."
Polymer is almost fully functional.
Currently it is missing routing for example but this doesn't mean you can't do this with Polymer.
There is now https://elements.polymer-project.org/elements/app-route
In Dart also dependency injection works fine with Polymer because of the types. If it's possible in Dart, it's possible in JS as well because Dart transpiles to JS. DI in plain JS might be more cumbersome though.
In this package (Dart)
https://github.com/bwu-dart/bwu_polymer_routing
I made the routing and DI packages used by Angular.dart available for Polymer. There are also routing packages for Polymer.js available.
I put together some router demos. The "missing parts" really depend on what type of application you're building.
https://github.com/erikringsmuth/polymer-router-demos
I've used it as both, as an enhancement to an app written in another framework, and as the full framework itself, where it was responsible for every element on the page.
I really like just about everything about Polymer, so I've been very happy using it for the whole app, even built my own router. If you've got an existing app I'd recommend dipping your toe in the water, as Polymer works great composed into other apps to see if it's to your liking.
Let me give this another try:
The key behind web-components (and thus Polymer) is, that they are self-contained. You have a web-component somewhere, you import it, and (if you're lucky) it just works, wherever it comes from. The web-component will NOT interfere other components. So doing things like MVC is not Polymers business (although it provides a data-binding mechanism), as this belongs to the process of tying things together. It is considered to be best practice that these kind of things are solved by creating new elements too, that create and react to events. When it comes to the model you code non-visual web-components, that don't have/need a template. TodoMVC has an (outdated) example for that (https://github.com/tastejs/todomvc/tree/gh-pages/examples/polymer).
So Angular gives you a path to follow on how to do MVVM, whereas it is up to you on how to do the "logic" in your app when using Polymer. IMHO Angular is for more complex and rather enclosed apps, whereas Polymer is for any kind of app, that embraces the web. You even can use Polymer, if you're not writing an app at all ;)

Getting Started with Durandal

I'm interested in building a SPA application. From what I can tell, Durandal provides the majority of what I'm looking for. Except, I'm looking for the most basic possible example that uses durandal. The sample app that's included uses bootstrap and sammy.
Is Bootstrap and Sammy required? If not, is there a sample I can see somewhere that doesn't have the code? I just want a basic app with two screens to use as an example. Yet, I can't seem to find the bare minimum example anywhere.
Thank you,
Version 1.20 of Durandal uses Sammy.js for routing if you include the optional router plugin. It is not necessary, but a pretty good idea to use it to simplify learning Durandal without having to learn how to route.
Durandal 2.0 is scheduled for release this month that gets rid of Sammy.js's dependency and has it's own router.
To find an example or sample app using Durandal that doesn't rely on either Sammy.js or Bootstrap will be difficult because they are easy to include, everyone understands them, and it's hard to go wrong when using these to simplify a sample app.
If you are looking for a very simple sample you can look up John Papa's CodeCamper JumpStart, but it includes a lot of other dependencies. The Durandal Starter Kit however is available on nuget and from durandaljs.com and has a single view and is an excellent way to start learning Durandal.js.

Categories

Resources