I can see my alias present in app aliases array:
dd(app()); // ... "Me\Package\Facades\PHPFile" => "PHPFile"
using that same full name works
dd(
\Me\Package\Facades\PHPFile::load('app/User.php')
);
BUT trying to use the registered alias:
dd(
\PHPFile::load('app/User.php')
);
// Error: Class 'PHPFile' not found
Even though it was registered in app()! Any ideas whats going on here?
In my package composer.json:
"extra": {
"laravel": {
"dont-discover": [],
"providers": [
"Me\\Package\\MyServiceProvider"
],
"aliases": {
"PHPFile": "Me\\Package\\Facades\\PHPFile"
}
}
},
Also tried adding this in my serviceproviders register method:
$this->app->alias('PHPFile','Me\Package\Facades\PHPFile');
Host application composer.json
add
"repositories": [
{
"type": "path",
"url": "/full/path/to/packages/Me/Package"
}
],
Then install with composer require "me/package #dev"
Thanks to #lagbox for spotting my error in comments
Related
I find the documentation at - https://devcenter.heroku.com/articles/app-json-schema#scripts - is poor. It doesn't list all of the different events which can be hooked into to run scripts. I want to run a script for when the app is first created and another with each release. The first is objective is already achieved with a script with runs on the "postdeploy" event. I can't see anything though to help with the second. If using a procfile I know I just specify the "release" process type but I'm trying to do this with an app.json file so I believe the procfile is not relevant.
Does anybody know how I can do what I want? Even better the whereabouts of this explained on Heroku.
At the moment I have this for my app.json -
{
"name": "accounts",
"success_url": "/users/signup",
"addons": [
{
"plan": "heroku-postgresql:hobby-dev"
}
],
"env": {
"NEW_USERS_ARE_SUPERUSERS": "0"
},
"formation": {
"web": {
"quantity": 1,
"size": "free",
"command": "gunicorn proj.wsgi"
}
},
"buildpacks": [
{
"url": "heroku/python"
}
],
"scripts": {
"postdeploy": "psql -c \"create extension pg_trgm\" $DATABASE_URL && ./bin/setup.sh"
}
}
Can I just add a "release" key to the "scripts" dictionary? I saw somewhere somebody had "heroky-postbuild" but that didn't seem to work when I tried it.
When I update project tags in nx.json, TSLint seems unaware that the tags have changed, and lints and builds the project even though the dependencies are violated.
Example
Currently my nx.json file looks like
{
"npmScope": "patient-engagement",
"implicitDependencies": {
"package.json": "*",
"tsconfig.json": "*",
"nx.json": "*"
},
"projects": {
"hep": {
"tags": ["scope:hep", "compatibility:ie10"],
"implicitDependencies": []
},
"mb-ui": {
"tags": ["scope:shared", "compatibility:ie10"],
"implicitDependencies": []
},
"utils": {
"tags": ["scope:shared", "compatibility:ie10"],
"implicitDependencies": []
}
}
}
And my root tslint.json includes:
"nx-enforce-module-boundaries": [
true,
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "scope:hep",
"onlyDependOnLibsWithTags": [
"scope:hep",
"scope:shared"
]
},
{
"sourceTag": "compatibility:ie10",
"onlyDependOnLibsWithTags": [
"compatibility:ie10"
]
},
{
"sourceTag": "scope:shared",
"onlyDependOnLibsWithTags": [
"scope:shared"
]
}
]
}
],
This passes linting as expected when I run ng lint hep.
However, if I edit the tags in nx.json, the linter does not show any errors. For example, if I modify nx.json to look like this (removing tags from the libraries), it still lints and builds without any errors.
{
"npmScope": "patient-engagement",
"implicitDependencies": {
"package.json": "*",
"tsconfig.json": "*",
"nx.json": "*"
},
"projects": {
"hep": {
"tags": ["scope:hep", "compatibility:ie10"],
"implicitDependencies": []
},
"mb-ui": {
"tags": [],
"implicitDependencies": []
},
"utils": {
"tags": [],
"implicitDependencies": []
}
}
}
If it's useful, when I update the rules in tslint.json, the linter DOES throw errors, but I would like it to also acknowledge changes to nx.json.
Is there a way I can get the linter to show errors when tags in nx.json are updated?
Nx caches a bunch of information concerning dependencies in generated file: /dist/nxdeps.json
You can simply delete this file to immediately see changes to nx.json.
It could also be VS Code's caching causing problems
You might need to restart the Typescript service before changes to tslint.json or tsconfig.json files go through.
ctrl + shift + p and then Typescript: Restart TS Server
In Webstorm, restarting the typescript service does not help but restarting IDE helps (looks like indexing files).
In my case, I am doing steps like this when editing nx.json:
Remove dir node_modules/.cache/nx
Run nx lint (will generate new cache)
Restart IDE
I am trying to setup custom commands on my raspberry pi 3 with google assistant SDK. I was following this guide to setup my custom command. Whenever I run gactions test ti would get the following error:
Pushing the app for the Assistant for testing...
ERROR: Failed to test the app for the Assistant
ERROR: The caller does not have permission
2019/05/16 17:50:23 Server did not return HTTP 200
I have used gactions update to upload my action definition json file, with the google account that owns the Google Action project, and it was updated successfully. Therefore I'm not sure why I would have no permission on a project I owned and with a successfully updated action json.
There is the json I had for my custom action.
{
"manifest": {
"displayName": "DJ Roomba",
"invocationName": "DJ Roomba",
"category": "PRODUCTIVITY"
},
"actions": [
{
"description": "Thanos Snap",
"name": "djroomba.name.ThanosSnap",
"availability": {
"deviceClasses": [
{
"assistantSdkDevice": {}
}
]
},
"fulfillment": {
"staticFulfillment": {
"templatedResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "You should have gone for the head"
}
},
{
"deviceExecution": {
"command": "action.devices.commands.ThanosSnap"
}
}
]
}
}
},
"intent": {
"name": "djroomba.intent.ThanosSnap",
"trigger": {
"queryPatterns": [
"Thanos snap"
]
}
}
}
],
"locale": "en"
}
I'm not sure if this will help, but I'm using Raspbian Jessie(since snowboy only supports up to that)
So, it turns out to be that I'll have to at least publish my action in alpha or beta version, otherwise the gactions test will not work
I have setup path aliases in my tsconfig.json which looks like sop
"paths": {
"#services/*": [ "./src/app/services/*" ],
"#interfaces/*": [ "./src/app/interfaces/*" ],
"#directives/*": [ "./src/app/directives/*" ],
"#enums/*": [ "./src/app/enum/*" ],
"#classes/*": [ "./src/app/class/*" ],
"#components/*": [ "./src/app/main/components/*" ]
},
They are then imported like so
import { PageStateNames } from "#classes/PageStateNames";
import { UsersService } from "#services/users.service";
However, for some reason everything works except for #enums and #classes. Can anyone help me figure out why? The paths are correct, in fact Visual Studio recognises the paths are correct but webpack (at-loader) cannot find the files. But it can recognise the paths for everything else
So I have a public directory in my localhost that contains some classes that I want to be able to use in my current laravel project.
So how will I include these, external classes/files in laravel?
I tried to add these files in my composer.json file,
"autoload": {
"classmap": [
"database",
"../public_classes/priceClass.php"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"../public_classes/priceClass.php"
]
},
and do composer dump-autoload, then when I tried to call the function, it won't work.
You don't need to add anything in composer.json if you're using PSR-4. For example, you can create PHP file in \app\MyClasses\MyClass.php and use this namespace in custom class: namespace App\MyClasses.
Laravel will autoload this class for you.
I also wanted to include a few classes in my Laravel Project for that I just copied the files in a new directory(app/Libraries) and assigned Package name to all the classes and followed PSR-4 Autoloading standard for all those class files and I have added following code in my composer.json.
...
"autoload": {
"classmap": [
"app/Libraries",
],
...
hope this will solve your problem...
Happy to help!!!
What I end up doing was I put the path to file in my composer.json, then do composer dump-autoload.
composer.json:
"autoload": {
"classmap": [
"database",
"../public_classes/priceClass.php"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"../public_classes/priceClass.php"
]
},
then, the file I wanted to add, I edit it into simple functions instead of oop ones.
priceClass.php:
<?php
function getPrices(){
/*
*
*
*Statements here
*
*/
}
?>
And call it in my laravel controller simply by
$prices = getPrices();
I did this, because when I tried to have something like:
class Prices(){
public function getPrices(){
....
}
}
then call it in my laravel controller:
$priceClass = new Prices();
$prices = $priceClass->getPrices();
I ended up having an error, something like: Prices class not found.