How can I install Zephir on Ubuntu? - php-extension

I would like to install Zephir on my Ubuntu machine.
The goal is to convert some of my existing code into a PHP extension, in order to get the benefits of faster execution.
Any pointers are more than appreciated.

Install zephir in Ubuntu..
You need download Zephir-master from https://github.com/phalcon/zephir
You nedd download json-c from https://github.com/json-c/json-c
1) sudo apt-get install gcc make re2c phpX phpX-json phpx-dev libpcre3-dev
2) Open folder Json-c
2.1) sh autogen.sh
2.2) ./configure
2.3) make && make install
3) Open folder zephir-master
3.1) ./install -c
4) zephir help for to test the correct installation

Please note Zephir is currently in Alpha stage and therefore bugs can be expected.
You need to have certain packages installed:
json-c
re2c
In the command line type:
sudo apt-get install libjson0 libjson0-dev libjson0-dbg
sudo apt-get install re2c
Once you have the required packages installed, you can generate the parser as follows:
./generate
Compile the extension (this is your code):
./zephir
The code produced is placed in ext/, there you can perform the standard compilation:
cd ext/
sudo ./install

Related

Question about laravel installation to laravel team members [duplicate]

When I run a composer update I get this error message:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Failed to download psr/log from dist: The zip extension and unzip command are both missing, skipping.
The php.ini used by your command-line PHP is: /etc/php/7.0/cli/php.ini
Now trying to download from source
What do I need to do to enable the zip and unzip commands so that composer can download dependencies?
Depending on your flavour of Linux and PHP version these may vary.
(sudo) yum install zip unzip php-zip
(sudo) apt install zip unzip php-zip
This is a very commonly asked question, you'll be able to find more useful info in the aether by searching <distro> php <version> zip extension.
For servers with PHP 5.6
sudo apt-get install zip unzip php5.6-zip
Not to belabor the point, but if you are working in a Dockerfile, you would solve this particular issue with Composer by installing the unzip utility. Below is an example using the official PHP image to install unzip and the zip PHP extension for good measure.
FROM php:7.4-apache
# Install Composer
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Install unzip utility and libs needed by zip PHP extension
RUN apt-get update && apt-get install -y \
zlib1g-dev \
libzip-dev \
unzip
RUN docker-php-ext-install zip
This is a helpful GitHub issue where the above is lovingly lifted from.
For Debian Jessie (which is the current default for the PHP image on Docker Hub):
apt-get install --yes zip unzip php-pclzip
You can omit the --yes, but it's useful when you're RUN-ing it in a Dockerfile.
For older Ubuntu distros i.e 16.04, 14.04, 12.04 etc
sudo apt-get install zip unzip php7.0-zip
I had PHP7.2 on a Ubuntu 16.04 server and it solved my problem:
sudo apt-get install zip unzip php-zip
Update
Tried this for Ubuntu 18.04 and worked as well.
I'm Using Ubuntu and with the following command worked
apt-get install --yes zip unzip
In case you're using a locale development environment like XAMPP, just locate the php.ini file (C:\xampp\php in my case), open it and remove the semicolon from the following line.
;extension=zip
Restart your Apache webserver and it will work fine.
On docker with image php:7.2-apache I just needed zip and unzip. No need for php-zip :
apt-get install zip unzip
or Dockerfile
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "zip"]
RUN ["apt-get", "install", "-y", "unzip"]
If you are using Ubuntu and PHP 7.2, use this...
sudo apt-get update
sudo apt-get install zip unzip php7.2-zip
I got this error when I installed Laravel 5.5 on my digitalocean cloud server (Ubuntu 18.04 and PHP 7.2) and the following command fixed it.
sudo apt install zip unzip php7.2-zip
For PHP8.2 (Windows)
As stated here: https://www.php.net/manual/en/zip.installation.php#zip.installation.new.windows
As of PHP 8.2.0, php_zip.dll DLL must be enabled in php.ini. Previously, this extension was built-in.
You will need to manually enable this extension within your php.ini by adding extension=php_zip.dll
For a list of installed extensions you can run:
php -m
or if you have grep installed even easier would be:
php -m | grep "zip"
Actually composer nowadays seems to work without the zip command line command, so installing php-zip should be enough --- BUT it would display a warning:
As there is no 'unzip' command installed zip files are being unpacked using the
PHP zip extension.
This may cause invalid reports of corrupted archives. Installing 'unzip' may
remediate them.
See also Is there a problem with using php-zip (composer warns about it)
PHP-ZIP needs some dependancies or library missing, depends on the image from Dockerfile you need to install them first
RUN set -eux \
&& apt-get update \
&& apt-get install -y libzip-dev zlib1g-dev \
&& docker-php-ext-install zip
PHP 8.1
apt-get install --yes zip
The shortest command to fix it on Debian and Ubuntu (dependencies will be installed automatically):
sudo apt install php-zip
Try this for PHP 7.4:
sudo apt-get install zip unzip php7.4-zip
And for PHP 8.0:
sudo apt-get install zip unzip php8.0-zip
After run
apt install php-zip
and run again
composer require ...
I get the next warning and suggestion
As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' or '7z' (21.01+) may remediate them.
As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' or '7z' (21.01+) may remediate them.
So I suggest install unzip first.
apt install unzip
Please check your composer status first
composer diagnose
If the status showing
zip: extension not found, unzip not available, 7-Zip not available
then
Open your XAMPP Server
Apache -> config button ->Click "PHP(php.ini)"
Find "zip"
";extension = zip will shown
Remove the semicolon and save the file
Restart your XAMPP Apache
Now
composer create-project laravel/laravel <<project_name>>
or
laravel new <<project_name>>
apt-get install zip
I'm running a docker container and this helped me
docker-compose exec app apt-get install zip
install 7 zip from this site https://www.7-zip.org/download.html this software unzips the files for you and solvesd the errors

Library not recognized in Linux environment

I installed "eclipse" and want to run "fxruby" on fedora "linux", but it does not work it.
The error says :
cannot load such file -- fox16 (LoadError)
I installed this file with command
gem install fxruby
but fxruby not exist in gem list.
How can i fix it?
The warning about the path you can safely ignore (at least for now). What the error is telling you is that you do not have the FOX development headers and libraries installed, so it couldn't build the fxruby gem. So you must install the fox development package - it may be named something like "fox16" or "fox16-devel", or something else depending on what version of Linux you're running. (If all else fails, you can build it yourself).
After that, compiling fxruby (using gem install fxruby) should work.
If you do want to build FOX yourself, here are (approximately) the steps:
1) Go to the FOX website http://www.fox-toolkit.org/ , and download the latest 1.6 (stable) version (at the moment, fox-1.6.57.tar.gz).
2) I would create a directory ~/src, then cd ~/src, and unpack the downloaded package, e.g., tar xvf ~/Downloads/fox-1.6.57.tar.gz (adjust the path according to wherever you have actually downloaded the package).
2) You should now have a subdirectory fox-1.6.57 (i.e., ~/src/fox-1.6.57/). Cd to it, and read top-level documentation in README and INSTALL.
3) Run the configure script, ./configure or ./configure --prefix=$HOME.
The difference between these invocations is that if you run a plain ./configure, the software will be installed under the default location /usr/local (this will require root access when installed), whereas the invocation ./configure --prefix=$HOME will result in the software being installed under $HOME. The latter will not require root access to install and probably is better if you're just installing the software for your own use.
4) I you are installing under your own home directory, create appropriate subdirectories: cd ~; mkdir bin include lib'. (The installation may take care of this, but it doesn't hurt to pre-create the directories.)
5) Now run make. That should compile and build the FOX libraries under the local directory (~/src/fox-1.6.57/)
6) Run make install. That will install the libraries under either the default location of /usr/local or your home directory ~ (depending on your configure option)
7) A this point, you should have the FOX libraries and headers installed. Now try gem install fxruby. (If you're going for a local install, probably gem install fxruby --user-install.)
solved for fedora
i installed all of them :
ruby-devel.x86_64
fox-devel.x86_64
sudo dnf install redhat-rpm-config
yum groupinstall 'Development Tools'
yum group info 'Development Tools' yum -y install gcc ruby-devel
rubygems compass
gcc compt gcc-c++-x86_64-linux-gnu.x86_64
gcc-c++
[
gcc-c++-8.2.1-4.fc28.x86_64 C++ support for GCC
libstdc++-devel-8.2.1-4.fc28.x86_64 Header files and libraries for C++ development
]
sudo dnf install libpng12-devel.x86_64
sudo dnf install libb2-devel.x86_64
sudo dnf install libX11-devel
sudo dnf install libXcursor-devel.x86_64
sudo dnf install libXext-devel.x86_64 libXrandr-devel.x86_64
gem install fxruby

Ruby gems with C extensions not building in Ubuntu

I'm trying to base a Dockerfile off of Heroku's new heroku/heroku:18 image (which uses Ubuntu 18.04) and running into some issues that I didn't have in their very old heroku/cedar:14 base image, I believe due to them having different preinstalled packages. (I updated the base image to heroku/heroku:18 because I want to use the webpacker gem and in Cedar-14 I was getting: Webpacker requires Node.js >= 6.0.0 and you are using 0.10.25. If there's an easy way to install a newer Node in the older base image I'd love to hear it!)
My problem is that no gems with C extensions (like puma, pg, msgpack, etc. etc.) install successfully with this new base Docker image. The error messages vary slightly from gem to gem but all generally say:
The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
Various GitHub issues with similar problems have had me try:
apt-get installing:
build-essential
libpq-dev
libssl-dev
openssl
libssl1.0-dev
gcc
gcc-5
automake
make
Using heroku/heroku:18-build instead of heroku/heroku:18
None of these solutions solves the issue.
For reference, here are the relevant parts of my Dockerfile:
FROM heroku/heroku:18
RUN apt-get update && apt-get install -y nodejs --no-recommends
RUN (mkdir -p /ruby && cd /ruby && curl https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.5.0.tgz -s -o - | tar xzf - --no-same-owner)
ENV GEM_HOME=/ruby/gems GEM_PATH=/ruby/gems
RUN gem install bundler
RUN bundle install

How to install ruby on linux in a specific folder

I try to install ruby and rails to start to learn ruby on rails.
I work on Windows. After many search and tries, I gave up and installed a fresh ubuntu 14 x64 in a VirtualBox.
I installed ruby with apt-get, but its files get spread all over the file system (/bin, /var...). So, I have to use always sudo and search all over the place when installing gems.
I would like, just like in windows, find a ruby tar.gz which I can decompress in a folder of mine, with all files at the same place, where I have the "control" over the files, and I can watch easily what it's hapenning while installing gems, rails, etc...
The problem : I cannot find any tar.gz (or similar archive) of ruby for linux which I simply can uncompress in a folder and work with it (I can manage the $path). The only one I can find is for Windows !
Thanks !
It sounds like what you want is Ruby's source code. Go to https://www.ruby-lang.org/en/downloads/ and look under "Compiling Ruby - Source Code". That's where you'll find the .tar.gz files you want. You'll need to compile and install it before you can actually use it. Installing normally copies files "all over the file system", but you can force it to install to a specific folder by passing the --prefix option to the ./configure script.
$ tar -xf ruby-2.2.1.tar.gz
$ cd ruby-2.2.1
$ ./configure --prefix=/my/ruby/dir
$ make && make install
You may need to install some dev packages in order to get it to compile, but any compilation errors should make it clear what you need.
These instructions are also described here.
Thank you Max for your response.
In case someone else tries to compile ruby on a fresh new ubuntu, this is what I had to do to build and use it with success :
Install missing dependencies :
get the latest "Stable Snapshot" from https://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz and not the "Current stable"
sudo apt-get install libffi-dev
sudo apt-get install zlibc zlib1g zlib1g-dev
sudo apt-get install openssl
sudo apt-get install libssl0.9.8 [[[ first, find the latest version with : apt-cache search libssl | grep SSL ]]]
sudo apt-get install ca-certificates
sudo apt-get install libssl-dev
sudo apt-get install libreadline-dev
Then :
Edit downloaded file tools/rbinstall.rb, goto line 714 and correct the typo :
change "rescue LoadErroe" to "rescue LoadError" (not corrected in date of 20 March 2015).
Run Max's instructions above
Don't move the ruby destination folder declared with "--prefix" (even if you try to correct the shells in ruby/bin)
Finally, for using rails :
sudo apt-get install libsqlite3-dev
sudo apt-get install nodejs ==> inorder to have a js runtime

Undefined reference to libusb_get_parent() - compiling freenect

I'd want to install some libraries in order to connect a Kinect 360 in a Raspberry following this link: http://www.kdab.com/setting-up-kinect-for-programming-in-linux-part-1/
First, I checked this on Ubuntu and all was fine.
However, when I want to build libfreenect (with make) this error is shown:
../lib/libfreenect.so.0.5.2: undefined reference to 'lisusb_get_parent'
collect2: ld returned 1 exit status
I'm new on Raspberry and I don't know how to fix this.
Any help is appreciated!! :)
Thanks!
I ran into the same problem, starting from a fresh install of Raspbian 2015-02-16. Apparently (based on this), the version of libusb you get with apt-get is old. My workaround, based on recommendations from that link and elsewhere, is to build libusb from the more recent sources and convince libfreenect to use that:
Grab the packages you'll need to compile libusb and libfreenect:
sudo apt-get install git cmake build-essential
sudo apt-get install freeglut3-dev libxmu-dev libxi-dev
sudo apt-get install libudev-dev
Remove the existing libusb, if it's there:
sudo apt-get remove libusb-1.0-0-dev
Grab the sources for libusb-1.0.18:
wget http://sourceforge.net/projects/libusb/files/libusb-1.0/libusb-1.0.18/libusb-1.0.18.tar.bz2
tar -xvf libusb-1.0.18.tar.bz2
Build and install the updated libusb:
cd libusb-1.0.18/
./configure --prefix=/usr --disable-static
make
sudo make install
Ugly hack to convince libfreenect to use the new libusb library:
sudo ln -s /usr/lib/libusb-1.0.so /usr/lib/arm-linux-gnueabihf/libusb-1.0.so
Then you should be able to build libfreenect.
sudo ln -s /usr/lib/libusb-1.0.so /usr/lib/x86_64-linux-gnu/libusb-1.0.so
when u r using x86_64 machine

Resources