What is the difference between component, extension & module in Yii - yii

I am new to Yii framework, and just came across module, extension & component inside protected folder.
Can anyone please differentiate all these theoretically as well as practically also.

Components are the classes which can help you write the business logic on the basis of your models. Suppose all of your model files are using the same logic, So that logic can be written inside component instead of writing for each controller.
Extensions are like the libraries, which basically are not dependent on your models, and hence can be reused anywhere in current or later projects. For example writing any email extension.
Module is a self-contained software unit that consists of models, views, controllers and other supporting components. In many aspects, a module resembles to an application. The main difference is that a module cannot be deployed alone and it must reside inside of an application. Users can access the controllers in a module like they do with normal application controllers.
I hope it will help you.

Adding my 2 cents here...
Component
your own class file you want to do something with, specific to this site only. Examples are zip compression class in an uploader app, custom encryption algo for some security app
Extension
An external class file or group of files which are re-usable, often provided by 3rd parties. Examples are facebook connect library you or someone else built, api library from ebay.com to get listing, rss reader library to read from google etc.
Module
A mini- yii based site which serves as a subset of your site,can also be reusable in other applications or is build independent to make yii even more modular. Examples are , a forum module that is independant of the site but uses only logged in user info, a user authentication module which contains integration with several sites like openid, facebook and google

Related

Multiple web MVC projects in one SLN and routing to the correct view folder

Background: I'm working on a project to compare the different ways of building an api alongside the different ways to present views to the client. Namely, comparing a level 2 REST API, a level 3 REST API (with HATEOS), and a GraphQL api.On the client I want to compare a standard MVC web application, a Razor one, and an Angular one. You can see the current state of my project here. I used a couple of Pluralsight courses to configure identity server. Its nothing special and its mostly a bunch of random features for the sake of learning.
I dont want to duplicate a ton of logic and I enjoy the challenge. So I want to find a way to serve the different projects in the same sln. So far I've configured the authentication, data layer, and server projects.
The server is where the main and startup classes live.
Question: How can I serve views from controllers in different projects. In API. Authentication I want the Login views kept in that project.
I used this SO question to get me pointed in a direction:
How to specify the view location in asp.net core mvc when using custom locations?
In my Startup class I have this:
services.Configure<RazorViewEngineOptions>(options => {
options.ViewLocationFormats.Clear();
options.ViewLocationFormats.Add("/API.Authentication/Views/{1}/{0}" + RazorViewEngine.ViewExtension);
});
When I go to localhost:8000/login it errors but it says that its looking in the correct location.
How can I configure to point to multiple folders outside of the Startup Classe's directory?

Target Membership in React Native

I am involved to a project which is targeting multiple clients. We have to handle different client needs and so it can happen that a client wants to fully change a page in the application or they would like a different logic behind the screen. And of course we don't want to include one client's specific code to another code base, so separate our code with a kind of global variables is not an option.
On iOS it was really straightforward that we had to add a new target and select files to the target membership.
How we should handle it within a React Native project?
I found many articles about react-native-config, but it is just about the global variables, URLs and so on.

Approach at designing ASP.NET Core 2 applications that share functionality

Currently I've been tasked to create a bunch of small-to-medium applications, each of them having some common functionality.
Implement a preapproved boostrap-based graphical design. Therefore, they will use the same assets, images, css and JavaScript components.
Share the same licensing-based mechanism. An application service will be built where it will scan a file or database to get the number of licenses available for each app, thus granting or denying access to users. The only thing that varies is the name of the application instance itself.
Use AzureAD authentication.
Each must use the same authorization mechanism. A claims-based mechanism will be built to retrieve the claims from the database, given a user AAD account.
Each must share the same administration console.This console will be the one needed to populate user information and common catalogs.
A service will be built, to show toast notifications within the apps.
An email notification service will be built, to send emails to users when triggered by business rules.
And some other, less important features, but these are the core ones.
A first, perhaps naïve approach, was to create an ASP.NET Core 2 solution for each application, and implement the shared functionality in a sort-of Core assembly that can be shared by each app. However, while this could work for points 2 to 5, I'd still be repeating the graphical UI design for each app (basically, copying the wwwroot folder as well as the shared razor views five times). So, a change tomorrow in a CSS would have to be replicated five times.
Another approach would be to create a single ASP.NET Core 2 solution, implement the shared functionality and the UI, and then use the "areas" feature o ASP.NET Core 2, each area being a different app. The problem to this approach is shipping the app: if I have to install the five apps in a customer's server, no problem. If I have to install, say, only two apps, then I'd have to ship the five apps anyway and find a way to disable the other three apps.
So, I'd like to know if there is a feature in ASP.NET Core 2 for handling this type of scenarios, or alternatively, what are industry-standard architectural designs that could apply here.
In Windows Presentation Foundation with Unity, I can create a common shell, and then load modules in that shell, within the same shell window. So, using configuration files, I can add or remove modules as I see fit. What I'm looking is something similar in concept. I do not want to create five ASP.NET Core solutions and copy-paste the wwwroot folder and implement the same mechanisms of authorization, notification, email, etc., but rather, find a way to load the core, common features and then load additional features.
Thanks in advance.

How to properly use Yii modules?

In Yii PHP framework, one has ability to create modules. As per Yii's official documentation here is definition of the module:
A module is a self-contained software unit that consists of models,
views, controllers and other supporting components. In many aspects, a
module is similar to an application. The main difference is that a
module cannot be deployed alone and it must reside inside of an
application. Users can access the controllers in a module like they do
with normal application controllers.
Let's say we have a huge aplication and we have to create front-end and backend. In this case, is it better to create frontend module, and backend module and use them, or it is better to implment frontend as one Yii application, and backend as second Yii application.
I'm asking this because if you look at Yii's 2 advance template, there three are different applications (common, backend, frontend), but they are not implemented as three different modules, and my question is why?
Is app is going to be slower when you use modules and what are pros and cons of using modules?
Yii2 advance template has 3 different applications however they are frontend, backend and console (not common).
is it better to create frontend module, and backend module and use them?
The answer is "it depends". Lets take some examples:
I have a "users" section in the backend that tells the system what can each user change in the backend. I use this in multiple applications with no change at all so I have created a user module that I can just insert wherever I want. It is the simplest module because I never use it for the frontend.
a blog module, the blog module is a little more complicated as it has a place to manage the blog (this part is in the backend) and the posts and comments shown in the front section (this part should be in the frontend). However I still want to be able to plug it in multiple applications. My solution was to create some folders in the actual module (I actually created the same structure frontend / backend / common). The logic is the same, in my website frontend I use what you find in the frontend folder of the module, the common holds the things that I use in both the frontend and backend (like some models) etc. Different application will use the same frontend controllers / widgets but make sure you allow the views to be changed.
The answer to use or not to use modules is actually the same answer to "Will I use this in other applications and can it function without the rest of the application?" A module should NOT be tight coupled with the rest of the application.
The idea of the modules in that they almost autonomous.
At the stage of application development you must highlight from it all stand-alone elements.
For example, I have a large CRM. I need a user module (includes all models associated with the user, controllers, display
components and their configuration - for example the rules of routes). There is also an administrative module.
There CRM module and a module for corporate events and meetings schedules.
And about 3-5 independent modules - for example internal communications module,access control module and module of electronic payments.
The convenience is that the all modules are self-contained. They have their own MVC- sets, sets of widgets and configurations.
And they can be moved from one project to another without much effort.
Here's another interesting modular system:
There are resource with various functionality. It can be divided into modules. Each module file should implement a modular interface (you need to write it).
For example, I want each module to provide its own widget for menu.(Drop-down list or just a button) and its own widget for dashboard.
Also in the module file specified access to various actions, etc.
There is a basic component,that prior to the step of rendering polls all modules at their regulated functionality and builds on its basis the menu, dashboard and other widgets.
The main thing with this approach, keep in mind, that everything that module provides must be prepared by the modular functionality(models, widgets) not to disrupt the modular autonomy.

Tracking file changes done by an external apps

Is it possible to get a handle on a file which is opened by any external app via my application?
Using Cloud-Storage Apps as an example, I would like to track changes to a file opened via the Storage-Provider App, so the manipulated file can be uploaded again afterwards.
There are two possible answers here, depending on what kind of app you're implementing.
For general tracking purposes, you can try using the ContentsChanged event of the StoreFolderQueryResult/StorageFileQueryResult classes within Windows.Storage.Search. That is, you create a file or folder query for what you want to watch, and then register an event handler. Generally speaking, this works well for stuff on the local file system; it's not guaranteed if you're trying to run a query on files/folders whose backing store is elsewhere.
The subject is too detailed to be described here, but you can refer the "File and Folder Queries" in Chapter 11 of my free ebook Programming Windows Store Apps with HTML, CSS, and JavaScript, Second Edition, page 607. Even though I focus on JS as a language, the discussions of WinRT APIs like this are useful when working in any language...plus the ebook is free so there's nothing to lose.
The other mechanism would be useful if you're implementing an app that provides the interface to a cloud storage backend, like the OneDrive app that's part of Windows. In this case you'd want to use the CachedFileUpdater contract. See Appendix D, page 1288, of my aforementioned book.