How to get the ZFTool working? - zend-framework2

The ZFTool isn't working (anymore) on my Debian VM.
$ which zf
/usr/local/bin/zf
$ ls -lia /usr/local/bin/ | grep "zf"
... zf -> /usr/share/.composer/vendor/bin/zf.php
$ cd /usr/share/.composer
$ composer info | grep "zftool"
zendframework/zftool v0.1.0 Utility module for Zend Framework 2 applications.
$ echo $COMPOSER_HOME
/usr/share/.composer
Now when I start it:
$ zf create module Foo
OR
$ $COMPOSER_HOME/vendor/bin/zf.php create module Foo
OR
$ php $COMPOSER_HOME/vendor/bin/zf.php create module Foo
I get this error:
Reason for failure: Invalid arguments or no arguments provided
So I cannot run the ZFTool jobs like config, classmap generate etc.
What is the issues caused by and how to get the ZFTool working?

You're simply providing incorrect arguments as it says. That error is coming from withing ZF2 so you're triggering it, but there's There's no -h option.
try
./vendor/zendframework/zftool/zf.php
or
./vendor/bin/zf.php
no arguments and from within your root directory, you'll get a list of options.

Related

How to instsall nix-linter

I've tried to install nix-linter with 3 way. None works
nix package manager
nix-env -iA nixpkgs.nix-linter
Package is marked as broken, refusing to evaluate.
It propose me several option to add broken package ( export NIXPKGS_ALLOW_BROKEN=1 ). But I don't understand exactly what will be the repercutions. I prefer not to follow this option
with cachix
I follow this tutorial
and add this line
echo "trusted-users = root myusername" | sudo tee -a /etc/nix/nix.conf && sudo pkill nix-daemon
normally after cachix use nix-linter there is a cache that nix-build use
But it doesn't work. I get an error saying that there is no default.nix in my repository
https://github.com/Synthetica9/nix-linter
cachix use nix-linter
git clone https://github.com/Synthetica9/nix-linter
cd nix-linter
$(nix-build -A nix-linter)/bin/nix-linter --help
error: attribute 'nix-linter' in selection path 'nix-linter' not found
-bash: /bin/nix-linter: No such file or directory
somebody from cacheix said that this package is no longer maintain and I should try statix.
statix works

xonsh "which" equivalent - how to test if a (subprocess mode) command is available?

I would like to test (from xonsh) if a command is available or not. If I try this from the xonsh command prompt:
which bash
Then it works:
user#server ~ $ which bash
/usr/bin/bash
But it does not work from xonsh script:
#!/usr/bin/env xonsh
$RAISE_SUBPROC_ERROR = True
try:
which bash
print("bash is available")
except:
print("bash is not available")
Because it results in this error:
NameError: name 'which' is not defined
I understand that which is a shell builtin. E.g. it is not an executable file. But it is available at the xnosh command prompt. Then why it is not available inside an xonsh script? The ultimate question is this: how can I test (from an xonsh script) if a (subprocess mode) command is available or not?
import shutil
print(shutil.which('bash'))
While nagylzs' answer led me to the right solution, I found it inadequate.
shutil.which defaults to os.environ['PATH']. On my machine, the default os.environ['PATH'] doesn't contain the active PATH recognized by xonsh.
~ $ os.environ['PATH']
'/usr/bin:/bin:/usr/sbin:/sbin'
I found I needed to pass $PATH to reliably resolve 'which' in the xonsh environment.
~ $ $PATH[:2]
['/opt/google-cloud-sdk/bin', '/Users/jaraco/.local/bin']
~ $ import shutil
~ $ shutil.which('brew', path=os.pathsep.join($PATH))
'/opt/homebrew/bin/brew'
The latest version of xonsh includes a built-in which command. Unfortunately, the version included will emit an error on stdout if the target isn't found, a behavior that is not great for non-interactive use.
As mentioned in another answer, which exists in the current version of xonsh (0.13.4 as of 15/12/2022) so your script would work. However, it outputs its own error message so it's necessary to redirect stderr to get rid of it.
Also, unless you redirect its stdout as well (using all>), it migh be a good idea to capture its output so the final version would look like this:
#!/usr/bin/env xonsh
$RAISE_SUBPROC_ERROR = True
try:
bash = $(which bash err> /dev/null)
print(f"bash is available: {bash}")
except:
print("bash is not available")

nix-shell can't find standard attribute

I'm running nixos 19.09 and trying to follow along with the instructions for creating a ruby package. But in one of the first steps I'm getting an error that the withPackages attribute can't be found.
Command:
$ nix-shell -p "ruby.withPackages (ps: with ps; [ nokogiri pry ])" --show-trace
Result:
while evaluating the attribute 'buildInputs' of the derivation 'shell' at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/pkgs/build-support/trivial-builders.nix:7:14:
while evaluating 'getOutput' at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/lib/attrsets.nix:464:23, called from undefined position:
while evaluating anonymous function at /nix/store/b6cqdsczmwxfkmc65483x7fgwdl129ar-nixpkgs-19.03.173684.c8db7a8a16e/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:141:17, called from undefined position:
attribute 'withPackages' missing, at (string):1:94
I'm guessing that I messed up my nix store somehow, but I don't know how to debug it.
Additional Info:
$ echo $NIX_PATH
$HOME/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
$ nix-channel --list
nixpkgs https://nixos.org/channels/nixos-19.03
unstable https://nixos.org/channels/nixos-unstable
$ sudo nix-channel --list
<blank>
After #RobertHensing pointed out that it looked like I was on 19.03, and asked me to print out my channels, I tried just updating the channel list to point to 19.09 instead of 19.03 (with nix-channel --add) and that fixed it.

8th wall web app setup child compilation failed

I am new to 8th wall. I have cloned 8th wall web from git and executed below steps properly
# cd <directory_where_you_saved_sample_project_files>
# cd serve
# npm install
# cd ..
# ./serve/bin/serve -d <sample_project_location>
but on execution of last step which is for ex.
./serve/bin/serve -n -d gettingstarted/xraframe/ -p 7777
I am getting below errors
Failed to compile.
Error: Child compilation failed: Entry module not found: Error:
Can't resolve
'C:\8thWall_Project\web\serve\bin\gettingstarted\xraframe"
\index.html' in 'C:\8thWall_Project\web\serve': Error: Can't resolve
'C:\8thWall_Project\web\serve\bin\gettingstarted\xraframe"
\index.html' in 'C:\8thWall_Project\web\serve'
compiler.js:79 childCompiler.runAsChild
[serve]/[html-webpack-plugin]/lib/compiler.js:79:16
Compiler.js:306 compile
[serve]/[webpack]/lib/Compiler.js:306:11
Compiler.js:631 hooks.afterCompile.callAsync.err
[serve]/[webpack]/lib/Compiler.js:631:15
Hook.js:154 AsyncSeriesHook.lazyCompileHook
[serve]/[tapable]/lib/Hook.js:154:20
Compiler.js:628 compilation.seal.err
[serve]/[webpack]/lib/Compiler.js:628:31
Hook.js:154 AsyncSeriesHook.lazyCompileHook
[serve]/[tapable]/lib/Hook.js:154:20
Compilation.js:1325 hooks.optimizeAssets.callAsync.err
[serve]/[webpack]/lib/Compilation.js:1325:35
Any idea or pointers what is missing?
Thanks
I don't know why, but bat file don't want to be opened by path. Just go to the serve\bin directory and launch bat from here, like that:
7777 is unnecessary. problem was, that it can't find path to your xraframe
project, as you are in another directory, so you have to go tow directories up in ypur path for xraframe
It seems as if you're attempting this on a Windows computer. The serve process for Windows is slightly different than on macOS.
Instead of the normal serve script, use the serve.bat executable.
serve\bin\serve.bat -n -d gettingstarted\xraframe -p 7777
https://docs.8thwall.com/web/#locally-from-windows

swagger-codegen custom generator ClassNotFound

I'm writing a custom generator for swagger-codegen. When I attempt to run the generator with
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i path/to/swagger.json -l com.my.company.codegen.MyGenerator -o outputlocation
it fails with
Can't load config class with name com.my.company.codegen.MyGenerator
... list of built-in generators...
at io.swagger.codegen.CodegenConfigLoader.forName(CodegenConfigLoader.java:31)
at io.swagger.codegen.config.CodegenConfigurator.toClientOptInput(CodegenConfigurator.java:286)
at io.swagger.codegen.cmd.Generate.run(Generate.java:186)
at io.swagger.codegen.SwaggerCodegen.main(SwaggerCodegen.java:35)
Caused by: java.lang.ClassNotFoundException: com.my.company.codegen.MyGenerator
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at io.swagger.codegen.CodegenConfigLoader.forName(CodegenConfigLoader.java:29)
... 3 more
I'm not having trouble with any of the built-in generators.
What I did to get here (following the readme):
cloned the project
mvn package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar meta -o output/myLibrary -n myGenerator -p com.my.company.codegen
and then the above code
I also tried running mvn package again after making my custom generator (which did not make a .jar file anywhere I could find), and tried creating the .jar file myself. Got the same error.
Also FYI, my confusion was definitely increased by some apparent documentation inconsistencies: expected location for my module differs between here and the classname expected here (end of that section). Also, the command for making your own module specifies modules/swagger-codegen-distribution... when I believe it should specify modules/swagger-codegen-cli.... And the guidance in the project readme doesn't seem very congruent with the custom module readme that is generated here.
I don't normally work with Java, so apologies if I'm just missing something super obvious. Thanks in advance for any help!
After trying a bunch of things / internetting, here is what worked:
java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen generate -i path/to/swagger.json -l com.my.company.codegen.MyCustomCodegenGenerator -o outputlocation
Here are the steps I had to take start to finish to create a custom generator:
git clone from source
cd swagger-codegen
mvn package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar meta -o output/myLibrary -n myCustomCodegen -p com.my.company.codegen. This will create output/myLibrary and subdirectories, where you should find myCustomCodegenGenerator.java ("Generator" is appended to the class name you specify in the command). You should also be able to find the mustache templates within the resources subdirectory.
Make whatever changes you want to myCustomCodegenGenerator.java and the templates.
cd output/myLibrary
mvn package
cd ../..
Now generate your custom library: java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen generate -i path/to/swagger.json -l com.my.company.codegen.MyCustomCodegenGenerator -o outputlocation (building in step 7 should have generated target/myCustomCodegen-swagger-codegen-1.0.0.jar for you)
Notes:
Obviously the cding is based on where I put things, just wanted to be clear on relatively where I was when running commands
If you are just using the default generated base class for your generator (instead of subclassing an existing language), you will get an exception FileNotFound for myCustomCodegen/myFile.mustache -- it's from this optional block which you can just comment out of your custom generator class.
Remember to mvn package your custom module when you make changes
You'll need to include your custom library in the java command. For example:
java -cp path/to/your/jar.com:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
-jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
{args}
Note that if you are attempting to create a generator in Windows and run it from PowerShell, I had to modify #baylee's steps as follows:
mvn install
and
java -cp 'output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar;modules/swagger-codegen-cli/target/swagger-codegen-cli.jar' io.swagger.codegen.Codegen -i path/to/swagger.json -l my-language -o outputlocation

Resources