Yii2 include file to project - yii2

Now I have one twitter api library (TwitterAPIExchange.php).
What I want to do is just to autoload it to project and make it available all model/controller.
Is it possible? Please help!!

Add in your composer.json in require block this line:
"J7mbo/twitter-api-php": "*"
And in console run composer update.
In your models or controllers add use TwitterAPIExchange; and TwitterAPIExchange will be avaible in class.
More doc in https://github.com/J7mbo/twitter-api-php/wiki

Related

How to use docson widget with Sphinx on ReadTheDocs

I'm working on the documentation (https://global-coffee-data-standard.readthedocs.io) of my JSON schema (https://raw.githubusercontent.com/andrejellema/GlobalCoffeeDataStandard/master/schema/global-coffee-data-standard.schema.json)
The basics I have working (thanks to a lot of help from this forum) but now I would like to include the docson widget to show my code more beautiful (https://global-coffee-data-standard.readthedocs.io/en/latest/explanation.html#id13)
I've read this page https://threesixtygiving-standard.readthedocs.io/en/latest/_static/docson/README/ and I'm wondering how to install docson locally but more important on ReadTheDocs.
Do I need to run npm i docson localy? If so which files do I commit to my _static folder so ReadTheDocs can work with it as well?
Or can I put some magic in conf.py to let Sphinx handle it?
EDIT
I tried adding the docson files to my _static folder and it seems to work when I add this code to my ReST file:
<script src="_static/docson/js/widget.js" data-schema="https://raw.githubusercontent.com/andrejellema/GlobalCoffeeDataStandard/master/schema/global-unique-id.json"></script>
But only when I add just one docson widget. When I add more I get this error in the console:
only one instance of babel-polyfill is allowed.
So I'm assuming this is not the correct workflow.
What is the correct workflow to add multiple docson widgets to my page.

Partial Views in a Razor Class Library aren't found

I have a simple RCL with following structure:
/Pages
/Shared/
_Footer.cshtml
The content is very simple:
<h3> _Footer.cshtml partial view.</h3>
I also have a ASP.NET Core Web App project with same folder structure:
/Pages
_ViewImports.cshtml
-ViewStart.cshtml
/Shared
_Layout.cshtml
Somewhere in the layout file I make a reference to the partial view:
<partial name="_Footer" />
Here is the problem:
If I add a Project Reference of RCL to the Web App, the partial view is found and pages render fine.
If I make a Nuget package from the RCL, add it to a local Nuget source and add a reference to the package, the partial view won't be found.
The partial view '_Footer' was not found. The following locations were searched: /Pages/_Footer.cshtml /Pages/Shared/_Footer.cshtml /Views/Shared/_Footer.cshtml
What could be the difference between adding a project reference and Nuget reference? I've verified the Nuget package does contain both the Class Lib's default and views assemblies.
I found it works if you use dotnet pack instead of nuget pack. Note for dotnet pack package information is now read from csproj instead of nuget spec file.
In my case I wasn't even able to make it work in the scenario the op said it does work:
If I add a Project Reference of RCL to the Web App, the partial view
is found and pages render fine.
I was just getting the standard error message that the partial view was not found (even if the searched paths were correct).
After some head banging I solved this problem by adding the following xml block to both .csproj files:
RCL: e.g. RazorUIClassLib.csproj
Web App: e.g. WebApp1.csproj
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
I had the same problem, the solved writing the full path from the library Area, for example:
In the library i have:
Areas/Footer/Pages/_footer.cshtml
with my UI Proyect i called it like: <partial name="~/Areas/Footer/Pages/_footer.cshtml" model="My Model instance"/>
I hope it can help you
According to the docs (https://learn.microsoft.com/en-us/aspnet/core/razor-pages/sdk), I think you can use IncludeRazorContentInPack to include your .cshtml files in a NuGet package (it defaults to false).

Sharing components across multiple Aurelia projects

we started our project with ES6 javascript skeleton.
we would like to extract some styles and custom attributes to a common folder so we can use these at any Aurelia module we will build in the future.
the problem is with the bundle files. we don't know how to config them to bundle external folder out of the main ES6 folder.
can you please tell us what to do?
It sounds like you want to build an Aurelia plugin that you can import into any project. I would start by taking a look at the Aurelia plugin skeleton.
Once you've built your plugin with the custom styles and attributes you want, you'll want to either register it with jspm as a link, or publically through a registry such as npm or github.
Once published, you will be able to jspm install registry:my-package in any new project, and add the following line to your main.js file:
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.plugin('my-package');
}
For more information on this last step, see the brilliant answer provided by Ashley Grant here.

Using Alloy widget in Appcelerator project

I just found a website from where I can get alloy widgets http://alloylove.com/
Please tell me how to use/integrate downloaded widgets in my project.
You can use http://gitt.io/ instead of http://alloylove.com/ , because gitt.io can install widgets modules for you .
For example :- to install nl.fokkezb.loading widget http://gitt.io/component/nl.fokkezb.loading from your project root run this command
$ gittio install nl.fokkezb.loading
It`s easy .
You need to download the contents and put it inside the widget folder. Once that is done, update the config.json file. Once done, call createWidget call and you are good to go.

Cirrious.MvvmCross.ExtensionMethods not found in nuget Hot Tuna Starter Pack

I'm trying to develop my first application using mvvcross. I'm following this tutorial http://slodge.blogspot.co.uk/2013/04/n0-first-mvvmcross-application-n1-days.html but I don't know why can't use in my code this namespace Cirrious.MvvmCross.ExtensionMethods
To add all project's references I'm using Nuget and the version of Hot Tuna Starter Pack is 3.0.10
In this page, http://monodeveloper.org/uncategorized/building-cross-platform-mobile-applications-in-visual-studio-using-xamarin-and-azure-mobile-services/ there is a mvvmcross example, and if I download the source code and add the references that this project is using in the References folder, I can use extensions :(
Like this:
var activity = this.GetService<Cirrious.MvvmCross.Droid.Interfaces.IMvxAndroidCurrentTopActivity>().Activity;
What is the problem? Maybe related with PCL assemblies?
Thanks in advance!
The this.GetService<T> style of service resolution was replaced with simple Mvx.Resolve<T> calls and with constructor based dependency injection in MvvmCross v3.
For more information on this, see https://github.com/slodge/MvvmCross/wiki/Service-Location-and-Inversion-of-Control