I'm trying to get the PHP Core SDK to work without composer. There doesn't seem to be a simple way of working with the SDK without composer (https://github.com/paypal/sdk-core-php)
Any chance someone has an autoloader script or another solution to get this working?
I've been scanning for other information throughout the web, but it seems i'm the only person alive trying to get this to work without Composer.
Any chance? Thanks!
Alright, so it seems that i am really the only person on this planet who wants to do this. Well, then i'll answer my question myself. It seems like this is the guide for running every composer package without composer. Yihaa \o/. Probably easy stuff for most people using composer, but i've never used it because i'm on a shitty windows shared-host.
This is based on debian, but replace every apt-get with YUM for redhat or whatever.
So, i'm doing this in my root directory, don't whine about it :)
Ssh into your Linux Box (local mac or windows will work aswell but i'm not telling you)
# cd into the root directory (or user directory)
cd ~/
# install php5 and php5-curl and unzip (because the package we're
# getting is from GitHub). There might be other stuff your package is asking for.
# So just include it at the end
apt-get install php-5 php5-curl unzip
# install composer
curl -sS https://getcomposer.org/installer | php
# get the master archive
wget https://github.com/paypal/sdk-core-php/archive/master.zip
# unzip it
unzip master.zip
# cd into the directory
cd master
# move the files back to the ~/ directory
mv * ..
# remove the master directory
rm -r master
# install package using composer
php composer.phar install
# now we have the lib directory and the vendor directory. Lets tar that up
tar -cf package.tar lib/ vendor/
#we now have a tar file called package.tar copy that to your computer, ftp, whatever.
You can now create a directory in the place where you include all your stuff called lib-package (or whatever fancy name you'd like to call it) and add the following line in your project
require_once(/path/to/your/package/lib-package/vendor/autoload.php)
Voila, you're done.
Related
I'm new to AWS and I've gotten as far as getting the following error in Symfony:
Asset manifest file "/var/app/current/public/build/manifest.json" does not exist.
In local, this would be fixed by running npm run build. I've tried adding NPM_CONFIG_PRODUCTION=true in the environment variables, but I think that might just be for node.js apps?
I've also tried SSHing onto the EC2 instance and installing node on there, but I ran into errors trying to install either npm or nvm. I feel like this is the wrong approach anyway, since it seems like the idea of beanstalk is that you shouldn't need to ssh onto the instance.
Perhaps I should just include the node_modules folder in the zip uploaded, but since one of the recommended ways to produce the zip is to use git, this doesn't seem correct either.
After a lot of digging around, it seems like there's 3 options here:
SSH onto the instance(s) and the following worked for me (Amazon Linux 2 - ARM chip)
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum -y install nodejs
(cd /var/app/current/;sudo npm add --dev #symfony/webpack-encore)
(cd /var/app/current/;sudo npm install)
(cd /var/app/current/;sudo npm run build)
The problem with this, is if you have multiple instances that scale up and down with a load balancer, it isn't really practical to do this.
Add the above as a hook:
The following sh file could be put in the following directory: .platform/hooks/predeploy
#!/bin/bash
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum -y install nodejs
(cd /var/app/current/;sudo npm add --dev #symfony/webpack-encore)
(cd /var/app/current/;sudo npm install)
(cd /var/app/current/;sudo npm run build)
However, I've since learnt that it's best advised to just include the node_modules in the zip that gets uploaded. I guess this way the time to get the server up is reduced.
Include the node_modules folder in the zip that gets uploaded.
To include the node_modules folder, since this is naturally ignored by GIT, I used the EB CLI and added a .ebignore file, which is a clone of the .gitignore file, but includes the node_modules and public folders. Also be cautious in your build process that you're not including the node dev dependencies.
Background
I use a RedHat machine without root access, no access to the yum packet manager and no Docker support. This is the policy unfortunately at my work.
I have configured Apache and PHP using a tar file in a folder. Also done same for MongoDB, now I try to configure the PHP drivers for MongoDB according to these instructions:
https://docs.mongodb.com/drivers/php/
However I get stuck on the first bullet:
sudo pecl install mongodb
Problem
Do I need PECL? Can the extension be downloaded manually, and added to PHP?
I have tried to download the mongodb extension manually from:
https://pecl.php.net/package/mongodb
How to compile it mongodb.so? I tried to run pecl on a machine where I have root access then I saw it downloaded the mongodb-1.10.0.tgz and run make (in output when installing).
When I unpack the tgz file manually, I am not able to run make. How to use the makefile.frag? How to run make?
Here is a link on how to build mongodb.so:
https://www.php.net/manual/en/mongodb.installation.manual.php
git clone https://github.com/mongodb/mongo-php-driver.git
cd mongo-php-driver
git submodule update --init
phpize
./configure
make all
sudo make install
You can also unpack the mongodb-1.10.0.tgz file with:
tar -xvf mongodb-1.10.0.tgz
phpize
make all
sudo make install
I want to use php spreadsheet package and from their site, I was told to install composer on cpanel but have met little success on the internet trying to figure out how to do it.
Please, who can put me through on how to install composer on liveserver
You can use SSH for this (alternatively using cron jobs to run the commands will also work - way more tedious)
Login to your cPanel account via SSH
Make directory for your composer (can also be used for other executables that you might store)
mkdir ~/composer
cd ~/composer
Download composer
wget https://getcomposer.org/download/1.6.5/composer.phar
Change the name of composer and make it executable
mv composer{.phar,}
chmod +x composer
You will now be able to call composer by
php ~/composer/composer install
But it's more convenient to have it run by just invoking composer in your terminal. For this add the ~/composer directory to your $PATH. I'm using VIM for text editing so
vim ~/.bashrc
Append those two lines at the bottom
PATH=~/composer:$PATH
export PATH
Exit and login via SSH again - you will be able to freely call composer in your terminal
I started looking into using composer for my php project. i have MAMP Pro and would like to continue to use that for my development hosting. The problem is that I can't get composer to run anywhere accept in my /Users/***/ folder (where it runs really well). How would I get it to run in the root of my MAMP Server? I have messed with the .bash_profile file adding the following lines:
alias composer='php composer.phar'
export PATH=/Applications/MAMP/bin/php/php7.0.10/bin:$PATH
That does not work (and neither does the alias). The vendor file still shows up in the /Users/***/ folder.
Any help would be greatly appreciated!
You can do a global installation:
Since Composer works with the current working directory it is possible to install it in a system wide way.
1.Change into a directory in your path like cd /usr/local/bin
2.Get Composer curl -sS https://getcomposer.org/installer | php
3.Make the phar executable chmod a+x composer.phar
4.Change into a project directory cd /path/to/my/project
5.Use Composer as you normally would composer.phar install
Update: Sometimes you can't or don't want to download at /usr/local/bin (some have experienced user permissions issues or restricted access), in this case you can try this
Open terminal
curl -sS http://getcomposer.org/installer | php -- --filename=composer
chmod a+x composer
sudo mv composer /usr/local/bin/composer
Ok after looking at it a little bit more here's what I figured out using #Lokesh Gamot's answer and the composer site. Again, this is geared to use with MAMP.
Find the path of your development server. I would suggest putting var_dump(getcwd()); at the top of your index.php file to get the path to show up on your index page. For me, it was /Applications/MAMP/htdocs/.../web-root
Because I wanted composer in my server root, I inputted cd "/Applications/MAMP/htdocs/" into the terminal.
I then downloaded the file using curl -sS https://getcomposer.org/installer | php -- --filename=composer. This installs Composer into "/Applications/MAMP/htdocs/" as a file named composer.
When I begin a new project, I have to move the composer file into the project root using mv composer "/Applications/MAMP/htdocs/*Destination Root*" and then navigate the terminal to that same root by using: cd "/Applications/MAMP/htdocs/*Destination Root*". What I was missing was needing to move the composer file around to each root when I needed it.
After that, I can use composer using php composer. Again, thanks!
I need to install PEAR on a server which does not have outsite access to the net. There is no go-pear.bat in the php folder and even if it had go-pear.bat i think it needs access to the net.
I looked an the Installing PEAR from a local copy from the PEAR website. But it needs PEAR to be already installed for it to work.
So do any of you guys know how to install PEAR without access to internet?
You don't need PEAR installed on the webhost, just on your local machine.
The two main approches are
Track your dependencies manually, and copy all the appropriate files to the server yourself
With pear installed on your local machine, do pear install -R/my/root_dir -a PEAR. This will install the PEAR package and all dependencies to the specified root directory. Copy this installation to your webhost.
I think it's possible to use pear to manage an installation via FTP also. I never tried.
You should also have a look at "pear help" and "pear help install".
There is a way to do this if you are on Windows and have the PHP installer.
You can select, during the PHP installation time, the PEAR option under extension menu when selecting the components for PHP installation in order to install PEAR package.
If you already have PHP installed, you just have to click on the installer to choose "modify", and choose the correct option.
http://lh4.ggpht.com/_SDci0Pf3tzU/SgBXLClDWEI/AAAAAAAAEuI/TgnBA_SEHFs/s400/pear%20install.jpg
I wrote an article on this very subject:
http://christian.roy.name/blog/install-pear-without-network-no-internet-accessoffline
It will allow you to use the pear command as well.
Create temporary folder that I will get ride of later.
mkdir pear-temp
cd pear-temp
Upload all the PEAR packages to that temp folder (using SFTP, FTP, Whatever).
If you use a USB key, then you copy them all like this:
cp /mnt/usb/*.tgz ./
Extract the core packages in a separate folder.
mkdir lib
tar x -C lib -zf PEAR-*.tgz
tar x -C lib -zf Console_Getopt-*.tgz
tar x -C lib -zf Archive_Tar-*.tgz
tar x -C lib -zf Structures_Graph-*.tgz
This bash function is to be able to set the include_path joined by colons.
function join() {
local IFS=$1
shift
echo "$*"
}
pear requires output buffering and needs to load all the core packages from the lib folder.
PHPOPT="-d output_buffering=1 -d include_path=.:$(join ':' lib/*)"
First we setup our configuration file.
php $PHPOPT lib/PEAR-*/scripts/pearcmd.php config-create $HOME/ $HOME/.pearrc
Now we install ALL our packages. Make sure you have all the required dependencies as well.
php $PHPOPT lib/PEAR-*/scripts/pearcmd.php install -o -O *.tgz
Cleanup
cd ..
rm -Rf pear-temp
Put pear in your path:
PATH="$PATH:$HOME/pear"
Edit your .profile or .bashrc if you want this to be permanent.
Edit your php.ini too or add it using set_include_path() function, whichever :)
Drink to sucess!