Comments (31)
Hi Mayur
If you have registered the service provider correctly in your Laravel application, then you can inject the Cassandra library in any controller that you like.
You can find more about service providers and how to configure them in the documentatie of laravel: https://laravel.com/docs/5.3/providers
And about controllers: https://laravel.com/docs/5.3/controllers
Best regards,
Adam
from laravel-cassandra.
Firstly Thank You for replying. But i have few questions.
Is there need to ## change the database.php ?
Actually i cant figure out nothing that ## how can i connect to keyspace. Can you please explain step by step.
Thanks in advacne
from laravel-cassandra.
Hi Mayur
You can define the connection to cassandra in a cassandra.php file in the laraval config folder:
<?php
return [
/*
|--------------------------------------------------------------------------
| Cassandra contact point ip(s)
|--------------------------------------------------------------------------
*/
'contactpoints' => [
'192.168.100.11'
],
/* cassandra port number */
'port' => 9042,
/* default page size */
'defaultPageSize' => 25,
/* default consistency level */
'withDefaultConsistency' => (class_exists('Cassandra', false) ? \Cassandra::CONSISTENCY_ONE : null),
/* default connection keyspace */
'keyspace' => 'general'
];
The library will create the connection for you and you'll be able to execute queries to it
from laravel-cassandra.
is there any need to install datastax php-cassandra driver within project directory ?
from laravel-cassandra.
@mayur19 Nope, you need to install it as a php lib, what is your OS ?
Read official guide : https://github.com/datastax/php-driver/blob/master/ext/README.md#installing-cassandra-php-extension
from laravel-cassandra.
ubuntu 16.04 LTS . But now i have problem with php-cassandra driver when i upgrade from 14.04 to 16.04.
from laravel-cassandra.
is there any problem with php7 ? Because 14.04 having php5 but now 16.04 is comes with php7. So i think there is problem with php.
from laravel-cassandra.
@mayur19 Wat is the error you are running into exactly?
from laravel-cassandra.
getting nothing on this php -m | grep cassandra. So it means php-cassandra driver is not installed properly.
Is there any perfect documentation for the ubuntu 16.04 and php 7.0 ?
from laravel-cassandra.
@mayur19 , i've writed a doc to install on centOs with php7, it can help you with ubuntu & php 7, you have to find the right package name of php7 for ubuntu and use apt-get
Clean old package if exists
yum remove php-devel
yum remove php-common
# install php7 needed package
yum install php70w-fpm php70w-opcache php70w-cli php70w-ldap php70w-mbstring php70w-xml php70w-pdo php70w-mysqlnd
Build php-cassandra lib
Dependencies
yum install automake cmake gcc gcc-c++ git libtool openssl-devel wget gmp gmp-devel boost php70w-devel pcre-devel git
pushd /tmp
wget http:// dist.libuv.org/dist/v1.8.0/libuv-v1.8.0.tar.gz
tar xzf libuv-v1.8.0.tar.gz
pushd libuv-v1.8.0
sh autogen.sh
./configure
sudo make install
popd
popd
Build & install php-cassandra
git clone https://github.com/datastax/php-driver.git
cd php-driver
git submodule update --init
cd ext && ./install.sh
## update php.ini file :
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
## Sym link to make the lib work
ln -s /usr/local/lib64/libcassandra.so.2 /usr/lib64/libcassandra.so.2
Update php.ini file :
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
Sym link to make the lib work
ln -s /usr/local/lib64/libcassandra.so.2 /usr/lib64/libcassandra.so.2
from laravel-cassandra.
@vitoo i will try this one . I am stuck at this since 2-3 weeks but wont find any perfect solution.
from laravel-cassandra.
@websmurf if you have any documentation for installing php-cassandra driver on ubuntu then please share with me.
from laravel-cassandra.
I have installed php-cassandra driver correctly. But now still having problem while testing connecting between cassandra and php. When i run the php script , It showing empty page. Please help me. Now i am using ubuntu 14.04.
from laravel-cassandra.
Can you please enable the displaying of errors and try again?
A blank page normally means that there is an error, but it's simply not displayed
from laravel-cassandra.
When i look apache2 error log then it saying that PHP Fatal error: Class 'Cassandra' not found
Now i cannot figure out why this error is occur because apache2 already loaded the module. Extension is also enabled but still it is not working. Is there anything that i missed while installing php-cassandra driver ?
I performed following steps while installing php-cassandra driver -
sudo apt-get install g++ make cmake libuv-dev libssl-dev libgmp-dev php5 php5-dev openssl libpcre3-dev git
git clone https://github.com/datastax/php-driver.git
cd php-driver
git submodule update --init
cd ext
./install.sh
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> sudo /etc/php5/apache/php.ini
echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> sudo /etc/php5/cli/php.ini
Is there anything is missing ?
from laravel-cassandra.
Have you restarted php and apache ?
from laravel-cassandra.
yes. Several times. But still not working.
from laravel-cassandra.
Is php running as mod_php in apache? Or php5-fpm? And is apache installed on the same machine as the above output (php -m)? Or are you running it inside a VM of some sort?
from laravel-cassandra.
How can i check that it is running mod_php or php5-fpm ?
from laravel-cassandra.
That should be in your apache configuration defined somewhere. And that all depends on how apache is set up. Usually, it's inside /etc/apache2
from laravel-cassandra.
It is mod_php.
from laravel-cassandra.
Can you answer this questions as well?
And is apache installed on the same machine as the above output (php -m)? Or are you running it > inside a VM of some sort?
from laravel-cassandra.
It is installed same machine. Not inside a VM
from laravel-cassandra.
Can you create a php script and place that in you webroot somewhere with the following in it:
<?php phpinfo(); ?>
And check if the cassandra module is somewhere in the output?
from laravel-cassandra.
Nope . There is no cassandra module in that.
from laravel-cassandra.
Then most likely it generated the cassandra.ini for the CLI version of php, but not the mod_php version. In /etc/php5 there should be directories for CLI/FPM and (not too sure about the exact naming) for mod_php as well, can you verify that a cassandra.ini in the apache folder?
For fpm it should be: /etc/php5/fpm/conf.d/cassandra.ini
Not too sure about the exact path for mod_php
from laravel-cassandra.
No. There is no such file of name cassandra.ini
from laravel-cassandra.
I have installed php-cassandra driver in /home/my_username/php-driver . Is there any problem with this ?
from laravel-cassandra.
No idea to be honest, you should locate the directory with all other php settings and copy the cassandra.ini file from the CLI folder and place in the apache configuration directory for php. Then restart php and it should be visible in the phpinfo page
from laravel-cassandra.
Hey brother thanks alot . ## Now i just copied cassandra.ini into the /etc/php5/cli/conf.d and /etc/php5/apache2/conf.d . Now all work fine . Atleast it wont give any error about cassandra not found.
Thanks alot again for replying my questions.
from laravel-cassandra.
You're welcome
from laravel-cassandra.
Related Issues (2)
- Error with laravel 5.3 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-cassandra.