What is the right way to give Flatpak access to system binaries? - php

I'm using the flatpak version of Atom. A lot of my extentions require paths to executable binaries such as the php binary for code completion.
Now Flatpak blacklists the /usr directory, do when I pass the /usr/bin/php directory it doesn't find the proper binary even if the binary is installed and it's directory is added to the PATH environment variable of the flatpak.
So what is the correct way to do it? I've also stumbled upon flatpak versions of the binaries themselves as extentions of the org.freedesktop.Sdk package, but if I'm to use those, how do I pass them to an Atom extention that requires a path to an executable?
Addendum: I recognise that there are workarounds such as not using Flatpak Atom and using the deb package instead, or using a different IDE flatpak that has the required binaries provided, but I'm interested in a solution to this specific case.

By default the answer is no.. I saw your question went unanswered, so please try this. While this is for java, my hope is that you can try PHP... hope it helps you
However you can specify which ones you want..
Option 1:
add --filesystem=host option and then access them in the sandbox under /run/host.*
Option 2:
With Java 16 (1.16+) and later, & enable the custom Java path option
right click on the instance you wish to use Java 16 for > Click "Manage" > Enable "Custom Java Path" > And map the path to /app/jre/bin/java

Related

Configuring php-cs-fixer and PATH variable

A while ago, I successfully configured Atom to beautify my PHP using php-cs-fixer, but now I need to go through the same process on another Mac and can't remember exactly how I did it.
As a front-end dev, I'm not a PHP expert, but I understand that the Atom plugin is merely the middleman facilitating the actual fixing using php-cs-fixer, which, by default, it doesn't have access to. Once I installed the fixer, I had to add its location to my PATH variable. The confusing part is that I don't have the fixer installed via Atom (checked ~/.atom/packages) nor Homebrew (confirmed with brew list), however, the file is present in /usr/local/bin. If I move it, Atom returns the original error, so it's definitely using this file:
See https://github.com/FriendsOfPHP/PHP-CS-Fixer for program installation instructions.
Your program is properly installed if running 'which php-cs-fixer' in your Terminal returns an absolute path to the executable. If this does not work then you have not installed the program correctly and so Atom Beautify will not find the program. Atom Beautify requires that the program be found in your PATH environment variable.
Note that this is not an Atom Beautify issue if beautification does not work and the above command also does not work: this is expected behaviour, since you have not properly installed your program. Please properly setup the program and search through existing Atom Beautify issues before creating a new issue. See https://github.com/Glavin001/atom-beautify/search?q=php-cs-fixer&type=Issues for related Issues and https://github.com/Glavin001/atom-beautify/tree/master/docs for documentation. If you are still unable to resolve this issue on your own then please create a new issue and ask for help.
Hide Stack Trace
Error: Could not find 'php-cs-fixer'. The program may not be installed.
at PHPCSFixer.module.exports.Beautifier.commandNotFoundError (/Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:204:14)
at /Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:304:22
at tryCatcher (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromise0 (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:687:18)
at Async._drainQueue (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:138:16)
at Async._drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:148:10)
at Async.drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
at process._tickCallback (internal/process/next_tick.js:103:7)
which php-cs-fixer returns /usr/local/bin/php-cs-fixer and my PATH variable currently contains /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ourcore/.atom/packages/php-cs-fixer.
I guess my questions are, how is the fixer working if the PATH variable seems to be pointing to it in a different location, and how did it end up where it is? Does the location in my PATH matter at all, or does the Atom plugin know to look in /usr/local/bin? I just want to fully understand the entire process before repeating it.
EDIT: On further testing, I removed the Atom directory from my PATH and it didn't affect the plugin, so then I copied the file into the same directory onto the second Mac and it ran without issue, without needing to edit the PATH. Does the fixer file someone inform the OS?
Well first test "which php-cs-fixer" or "where php-cs-fixer" (depending on what os you're running) and if nothing is returned in the terminal then there actually is something wrong on the installation and the best thing to do is to manually install it.
Head to https://github.com/FriendsOfPHP/PHP-CS-Fixer and download it from there and follow the installation steps, after that it should all be good

G-Wan v 7.12.2 how to `completely remove the "Server: G-WAN"` and more

I've downloaded the latest G-WAN. I installed and ran successfully ph7.
How (what var should I use) if I don't want to reveal the server's identity?
I couldn't find LG_PH7 in the gwan.h file, is it the LG_PLI?
With the old version (4.x) I had a .c file in handlers helping me modify default language + query_char. This file now seems to get parsed (error on start if there is a mistake), but gwan doesn't seem to comply with it, e.g. default_char is still the default ?
Thank you
the query_char change does not seem to work
This is because the gwan/include files do not match the executable. This is confirmed by the missing PH7 enum value and 'default language' issue.
G-WAN v7 lets you change these options from your maintenance script, handler scripts, servlet scripts as well from the init.c script (found in the gwan root folder).
This script also lets you remove the G-WAN banner.
We have updated the download archive with the latest include files but you should also make sure that you are not using old gwan/include files from your previous version.
Thanks for Sasho and Bro.Ken for their prompt assistance.

which is the environment variables route for cakephp 3?

I recently installed a cakephp with composer to learn about framework use, and trying the bookmarks tutorial, but I get stucked in the checking your installation where you have to open the command line AKA cmd, and writing bin\cake.
It replies back: the system cannot find the path specified.
I've seen some information about how to set up the path variables but I'm guessing it's for version 2+ because apparently the cakephp 3 doesn't have a LIB folder like such:
YOUR_CAKE_DIR/lib/Cake/Console/
Any ideas on how to fix this?
Thanks
best regards!
***************UPDATE**********************
well, I've finally fixed the problem, the path I used for the cakePHP 3 instalation was:
c:\xampp\htdocs\caketest\bin
so I assume that If you aren't using xampp, it should point at the end to: cakeinstallation\bin...
my problem was that I always typed bin\cake but actually all I had to do was type only:
cake
you can read more information in here
bin\cake shouldn't require any special path settings other than being in the correct directory. However, you should make sure that php-cli is on your system's PATH. Depending on how you install PHP it could be in any number of places, but if php -v doesn't output the version of PHP you installed, you'll need to find where your installer put PHP and then setup the PATH environment variable.
With your example, AFAI remember the working directory they were executing cake binary was the parent of "bin" folder, in your case "caketest". I am talking without trying it (I dont have an environment close) you should use:
c:\xampp\htdocs\caketest> "bin/cake"
Watch the quotes. I think they are the main reason of that "the system cannot find the path specified."
I am supossing you are under windows (I saw xampp written in your post) and probably the xampp installation has already added the php folder in the PATH environment variable.

search contents in php files in Windows 7

I have spent a long time looking for a way to search a phrase across some of my php files in Windows 7.
Things I have done include:
enabling “Always search file names and contents” in Windows Explorer;
adding php in the list of “Index properties and File Contents to enable content search” in Indexing Options;
making sure the directory is indexed;
making sure I have the permission to that directory (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs).
What else should I try? Is that even possible to do that in Windows 7? If not, I’ll have to install Cygwin, which I am reluctant to do now.
Are you attempting to search the contents of each of the .php files themselves?
Or are you searching for a phrase in filenames with the corresponding .php file extension?
If your goal is the former, the following text editors can easily "Find all in open files" and even "Find all in folder(s)":
http://www.sublimetext.com/
http://notepad-plus-plus.org/
If what you're looking for is a command line option, the findstr command should serve you just fine. More information on findstr here.
If you're attempting to do the latter, then the link provided by Dany Caissy looks like it'll have just what you're looking for.
Linux/Unix has a grep command line utility for doing exactly what you want. If the built-in Win7 search/explorer capabilities don't do what you want, perhaps one of these links for third-party windows equivalents to grep:
Windows-equiv grep command line
Using Windows7 built-in findstr from command line
Note that Justice Cassel's answer has an excellent solution (search in all open files - +1 Justice), if you have your PHP files open in Notepad++. If you aren't using that NP++ for programming, you really should check it out. The FTP plugin (which automatically uploads a file every time you save it) is worth its weight, plus a dump truck, in gold.
In tools > folder options > search, you need to tick the box for always search file content.
Then when searching for a phrase e.g. "cats and dogs" you need to type the following in the search box
content:(~="cats and dogs").

Using mcrypt with phalanger

How to use a php extension like mcrypt? My first thought was to find mcrypt.php and simply include it (context.Include("mcrypt.php", false);), but of course that doesn't exist since it is written in C.
I was reading over Writing compiled PHP extensions in PHP post from the blog but that seems to be about creating your own extension for use in .net. But maybe Im wrong considering this statement: "Implement Phalanger extension in PHP langage. When you take your PHP library and compile it using Phalanger, the result is DLL working as any other extension"
But even still phpc (phalanger php compiler) is not going to compile c code as far as I know though I haven't tried.
these are the calls my php class is trying to make:
mcrypt_module_open
mcrypt_enc_get_key_size
mcrypt_enc_get_block_size
mcrypt is not yet reimplemented as managed Phalanger extension ... if you know some opensource alternative I can help with porting to Phalanger Extension.
For now, you can use native alternative (so you would have to run in x86). Simply open your .config (web.config for web app, or create app.config for desktop app), and add following
<phpNet>
<classLibrary>
<add assembly="php_mcrypt.mng, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4ef6ed87c53048a3" section="mcrypt" />
Jakub Míšek's answer is definitely right and if this post helps you please vote him up as well. However I wanted to simplify what he said as his advice still took me some time to understand what he was saying. Also please Jakub if you get a chance to read this correct me if Im wrong about anything.
First thing that got me about his answer was this file
php_mcrypt.mng
mng what is that????
But after digging through their [Phalanger] svn and the files located in
C:\Program Files\Phalanger 3.0\Wrappers
I found the mcrypt file. Also with some help from the php chat room I got a clue as to what the mng was, Managed Code.
So after adding the file as a reference as well as editing the web.config file to include it (as Jakub shows)
<phpNet>
<classLibrary>
<add assembly="php_mcrypt.mng, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4ef6ed87c53048a3" section="mcrypt" />
</classLibrary>
<scriptLibrary/>
</phpNet>
These lines must be feeding into Phalanger to load this extension when compiling (I think/know).
After that everything seems to compile and run fine! Thanks Jakub
It's not that complicated install and use MCrypt. For *nix users PHP.net provides a source of information in this page.
But for Windows there is not too much information.
However it's easy too. You just have copy the file libmcrypt.dll from a PHP Binary, save it in ext directory and enable it:
extension=php_mcrypt.dll
Note: In WINDOWS environment PHP EXtensions are usually anemd as php_ so you have to rename the DLL or the PHP.INI line above.
After that, restart Apache.
But before you do this, check your phpinfo() first because some packages and/or distributions comes with a pre-compiled static MCrypt.
Run it and check for with-mcrypt=static and/or MCrypt group with mcrypt support enabled

Categories