Trouble installing Clickatell Php Library - php

I'm trying to install the clickatell php library after this instruction:
https://github.com/arcturial/clickatell
But so far i was only able to install composer.
They say: this library uses composer and can be acquired using the following in your composer.json file.
{
"require": {
"arcturial/clickatell": "*"
}
}
So I have to add this to the composer json file? Then require the json file in my php script? I've no idea what to do next. Any help would be great.

When you are in your project root, run the following:
create a composer.json file with the following contents:
{
"name": "your/project",
"description": "project description",
"require": {
"arcturial/clickatell": "*"
}
}
php -r "readfile('https://getcomposer.org/installer');" | php
This will download a file called composer.phar
php composer.phar install
This will install the dependencies you specified in your composer.json file. Once complete, your project will now have a folder called "vendor".
Include the "vendor/autoload.php" file in your script
require_once __DIR__ . '/vendor/autoload.php';
...
Now you should be able to use the library as specified in the documentation.

Related

How to download CardConnect library by using Composer

I want to use https://github.com/Dewbud/CardConnect this library in my project but don't know how to download by using composer, library developer does not mention in the documentation.
They are listed at Packgist which means you can either add it to your project from the command line using the following command:
composer require dewbud/cardconnect
Or by adding the following to your composer.json file:
"require": {
"dewbud/cardconnect" : "2.*"
}

Use package installed via composer in Laravel

I have installed library called chosen js via composer. Now I have it in my composer.json file
"require": {
"harvesthq/chosen": "^1.8"
},
How can i use it in my project? Where do I need to require it ?
Install any packages in the Laravel
(1)first way: via composer
open project path in terminal and fire this command
composer require harvesthq/chosen
(2)Second way: add package name in composer.json file
"require": {
"harvesthq/chosen": "^1.8"
},
and fire this command
composer update

Codeigniter use third party class

So I want to use third party library form my project. This library calls "blockchainApi" and is stored in application/third_party/ dir.
so in my model I just use:
require_once APPPATH . '/third_party/blockchainApi/Blockchain.php';
$Blockchain = new \Blockchain\Blockchain(PAYMENTS_BTC_API_CODE);
and its load normal, but when I try to reach method from this class, it returns me error, method:
$response = $Blockchain->Receive->generate($data['wallet'], $data['callback_url']);
error:
Fatal error: Class 'Blockchain\Create\Create' not found in <..>blockchainApi/Blockchain.php on line 65
so the problem is:
this not working... so how to fix it?
I believe this guide is the best thing for you. And you will have a chance to use composer.
https://philsturgeon.uk/blog/2012/05/composer-with-codeigniter/
This is happening due to PSR-4 standards and not having an autoloader for namespaces
Edit:
From what I see here (link) you will probably need composer.
It is preferable to find a machine with linux. On terminal move to an empty folder run the following command:
curl -sS https://getcomposer.org/installer | php
Then you will have inside your folder a composer.phar file.
After that you create a composer.json file and inside you write:
{
"name": "project",
"description": "",
"license": "MIT",
"authors"
"require": {
"php" : ">=5.3.0",
"blockchain/blockchain" : "1.*"
},
"require-dev": {
}
}
Then run
composer.phar update
Then upload inside you project folder
- vendor (folder)
- composer.lock
- composer.json
Inside you index.php include the autoloader
include_once './vendor/autoload.php'
Optionally to run composer from everywhere by simply typing composer copy composer.phar to your local bin
cp composer.phar /usr/local/bin/composer
Then instead of composer.phar you can do:
composer update

composer does not generate autoload.php

i install composer for windows using this link http://getcomposer.org/download/ > http://getcomposer.org/Composer-Setup.exe
my web server is WAMP php 5.4 with openssl enabled.
i created composer.json with this code
{
"require": {
"doctrine/orm": "*"
}
}
and run with this code in .php file
<?php
// bootstrap.php
// Include Composer Autoload (relative to project root).
require_once "vendor/autoload.php";
and i got error Warning: require_once(vendor/autoload.php): failed to open stream
how to get composer's autoload.php?
why composer does not generate it?
how to use doctrine without composer?
Did you actually look to see if a vendor/autoload.php was created?
Did composer throw any error messages? Unless you got an error then I'm willing to bet that a vendor/autoload files was made. Is there anything in vendor?
I'm guessing that your bootstrap.php is not in your root directory (same directory as composer.json). If so you need to adjust the path in your require statement.
Remove the autoload part from your composer.json, then run composer install
This will generate an updated autoload object, good luck!
"autoload": {
"classmap": [
"..."
]
}

Using PHP Slim Framework

I want to use Slim for PHP in my project for the first time.
The manual says:
Install composer in your project:
curl -s https://getcomposer.org/installer | php
Create a composer.json file in your project root:
{
"require": {
"slim/slim": "2.*"
}
}
Install via composer:
php composer.phar install
Add this line to your application’s index.php file:
<?php
require 'vendor/autoload.php';
I'm afraid, I don't get it. Where should the commands "curl" and "php" be used? I only access my webspace through Filezilla. How can I then apply such a command?
What do those steps do anyway? Sadly, the manual is not helpful at all.
See http://www.slimframework.com/install:
MANUAL INSTALL
Download and extract the Slim Framwork into your project directory and require it in your application’s index.php file. You’ll also need to register Slim’s autoloader.
<?php
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
And there are links to zip-files.
If you're getting started on slim i'd definitely suggest that you get a good IDE that will guide you through the whole process. When I started the slim framework, I came across an IDE by jetbrains called PHPStorm. It makes everything so easy by doing most of the stuff you listed for you...
download and install PHPStorm https://www.jetbrains.com/phpstorm/download/
download and install Composer https://getcomposer.org/download/ so PHPStorm can use it.
get to the part where you start PHPStorm.
go to File > new Project > Composer Project and follow the motions.
It'll create all the files you listed. Then all you have to do is look and learn what it all means.
Composer is basically a package manager, you basically open a cmd and navigate to the place you want to create you PHP Slim application and type some composer commands to install package files in that folder. Composer then gets the packages and puts them in a directory called 'vendor' in that project folder of yours.
{
"require": {
"slim/slim": "2.*"
}
}
that's basically a config file that either you or composer will create in the same file also.

Categories