Push Notification in Laravel 4 - php

I am using Laravel 4 and I have a push notification system .
I had research and found a library support to :
https://github.com/davibennun/laravel-push-notification
I have configured as guide and when I run my routes as below :
Route::get('/push',function(){
$push = new \Davibennun\LaravelPushNotification\PushNotification();
$push->app('appNameAndroid')->to('My-device-token')->sent('my message'); }
It displayed an error :
Zend \ Http \ Client \ Adapter \ Exception \ RuntimeException
Unable to enable crypto on TCP connection android.googleapis.com: make sure the "sslcafile" or "sslcapath" option are properly set for the environment.
I thought the cause is my openssl problem (I am using LAMP in Ubuntu ) and try to all way I found on internet , even I also tried to run that script on Windows (XAMPP) and it's still not works .
any ideal ?
Update:
I had to go to vendor/zendframework/zend-http/Zend/Http/Client/Adapter/Socket.php and change its config['sslverifypeer'] to "null" and it's worked ! And it's only in local server, in live server , default setting could run perfectly !

Related

Varnish admin socket timeout with magento 1 in kubernetes

Outline:
We are trying to connect up varnish-4.1.11 to magento 1 in kubernetes using the nexcess turpentine addon, but the same error is returned each time:
Error determining Varnish version: Varnish admin socket timeout
Failed to load configurator
Application stack:
We have a kubernetes cluster running a magento 1 stack with the following containers:
php-fpm:7.2/nginx:latest
mysql:5.7
redis:latest
nfs-provisioner:latest
nginx:latest (acts as a proxy for varnish to point to)
varnish:4.1.11
kubernetes info:
Networking: cilium:v16.3
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.5", GitCommit:"20c265fef0741dd71a66480e35bd69f18351daea", GitTreeState:"clean", BuildDate:"2019-10-15T19:07:57Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
Varnish config:
NFILES=131072
MEMLOCK=82000
NPROCS="unlimited"
RELOAD_VCL=1
VARNISH_VCL_CONF=/var/www/html/site/var/default.vcl
VARNISH_LISTEN_PORT=6081
VARNISH_ADMIN_LISTEN_PORT=6082
VARNISH_SECRET_FILE=/etc/varnish/secret
VARNISH_MIN_THREADS=5
VARNISH_MAX_THREADS=50
VARNISH_THREAD_TIMEOUT=120
VARNISH_STORAGE="malloc,512M"
VARNISH_TTL=120
DAEMON_OPTS="-F -a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-f ${VARNISH_VCL_CONF} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-t ${VARNISH_TTL} \
-S ${VARNISH_SECRET_FILE} \
-s ${VARNISH_STORAGE}" \
-p esi_syntax=0x2 \
-p cli_buffer=16384
What we've tried so far:
Downgrading to varnish-3.0.7
Pointing magento to varnish's IP directly
Running a generic varnish connection script in PHP
Notes:
Pinging the varnish pod from the nginx/fpm pod works fine
Curling to the varnish ports from the nginx/fpm pod also works fine
The generic connection script noted above works successfully when run from inside the varnish container itself, which very likely indicates a networking issue.
Running the stack locally in docker-compose works fine, which also indicates a networking issue.
I appreciate that this is a very very niche issue, but hopefully someone else has some insight into what could be going wrong.
In case anyone else encounters this or a similar issue, it was due to the linkerd service mesh we have in place not properly passing traffic.
Whilst not an ideal solution, disabling linkerd for the relevant pods resolved the issue.

How to use Memcached for session in Laravel 5.7?

Normally I used file as driver to store session and cache. Now I want to work with Memcached to store session and cache on Laravel 5.7 application. It is new to me. I have already installed php-memcached on my local environment.
In my Laravel 5.7 web application I have configured session.driver and cache.default in the .env file as following.
SESSION_DRIVER=memcached
CACHE_DRIVER=memcached
I leave everything else with its default installation. When I refresh the page I get the following error.
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class 'Memcached' not found
/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php 69
I do understand that when you configure driver for session and cache config to use Memcached, the MemcachedConnector will get involved. It imports the Memcached class and tries to create an instance object of the Memcached class as following.
use Memcached;
class MemcachedConnector {
protected function createMemcachedInstance($connectionId) {
return empty($connectionId) ? new Memcached : new Memcached($connectionId);
}
}
With the above error, it seems like the Memcached class is missing. How can I solve it? Please do not tell me to do the following even it solves the problem.
SESSION_DRIVER=file
CACHE_DRIVER=file
or
SESSION_DRIVER=array
CACHE_DRIVER=array
Because I would like to use Memcached and would like to know what to do to make it work.
I can't comment yet so sorry for posting as answer.
Try running php -i || grep 'memcached' from your app directory.
If you're running vagrant, try vagrant ssh then php -i || grep 'memcached'
You could also (as suggested below) add phpinfo(); to the top of your routes/web.php (underneath the <?) and that should spit out your php info when you try to load your site in the browser.
This will clue you up as to whether or not memcached is installed and loaded or not.

cURL on local WordPress site returns: Error 6 (Could not resolve host)

I have a local WordPress installation running at: https://catalogue3.test.
Note that all .test domains should resolve to localhost, as I use Laravel valet. When I execute the following code in my Laravel project however, I get an exception as shown below.
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', "https://catalogue3.test", ['verify' => false]);
ConnectException
cURL error 6: Could not resolve: catalogue3.test (Domain name not
found) (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
When I run the command below in the terminal, the WordPress page is displayed.
curl https://catalogue3.test/ --insecure
Add
ip catalogue3.test
to your /etc/hosts file
I tried to add the domain to hosts and I tried to change dns in network settings, this answer is what worked for me.
Quick way to check if this is your problem is to do: curl --version
and php --ri curl
The versions should match. If they don't it's probably because brew
has installed curl-openssl. This can be removed by doing:
brew uninstall curl-openssl --ignore-dependencies
Maybe there's a way to configure the installed curl-openssl properly -
I've not investigated this yet.
I solved this adding catalogue3.test to /etc/hosts, even if I was using DnsMasq, and in theory, I wouldn't need it.
In my case (on macos) I had to add 127.0.0.1 as the first DNS server option in my WiFi settings.
Some useful info here too: https://github.com/laravel/valet/issues/736

Adding php-curl in a Yocto build

I've been building a custom image using Yocto and wpewebkit to use within docker. I need to run a local web server with php, which I have accomplished no problem. I need to use curl within my project and I have apache2, php, modphp, and curl installed. All I need is php-curl but I cannot find how to install this. Does anyone know how or if I can do this? I've put in all my efforts on googling multiple phrases but I only find how to install php-curl using apt-get or yum, or I get links to the meta-* directories which I have access to within my build files anyways.
If it helps at all, this custom image was based on the image provided from the following project on GitHub: https://github.com/resin-io-playground/resin-wpe/tree/master/base-image . I already spoke to the developer and their knowledge of PHP is limited.
EDIT #1: Progress so far, had to update the curl.bb file to properly include libcurl-dev, and then worked with #pmod's suggestion to incorporate curl into the php build. Everything seemed to run okay until I received the following error:
| ../php-7.1.9/configure: line 386: test: please: integer expression expected
| configure: error: reinstall
| ../php-7.1.9/configure: line 275: return: please: numeric argument required
| ../php-7.1.9/configure: line 285: exit: please: numeric argument required
| NOTE: The following config.log files may provide further information.
| NOTE: /base-image/build/tmp-glibc/work/x86_64-linux/php-native/7.1.9-r0/build/config.log
| ERROR: configure failed
| WARNING: /base-image/build/tmp-glibc/work/x86_64-linux/php-native/7.1.9-r0/temp/run.do_configure.29590:1 exit 1 from 'exit 1'
| ERROR: Function failed: do_configure (log file is located at /base-image/build/tmp-glibc/work/x86_64-linux/php-native/7.1.9-r0/temp/log.do_configure.29590)
ERROR: Task (virtual:native:/base-image/build/../meta-openembedded/meta-oe/recipes-devtools/php/php_7.1.9.bb:do_configure) failed with exit code '1'
Edit #2: I've gone ahead and added everything I was missing. I'm getting the same error above, where the function do_configure during the php build is failing. I'm posting below what I ensured I have in my curl.bb file (I had to add this), what I have in my php.inc file, and the curl files located staging directory.
curl.bb:
PACKAGES =+ "lib${BPN} lib${BPN}-native lib${BPN}-dev lib${BPN}-dev-native"
FILES_lib${BPN} = "${libdir}/lib*.so.*"
FILES_lib${BPN}-dev = "${includedir} \
${libdir}/lib*.so \
${libdir}/lib*.a \
${libdir}/lib*.la \
${libdir}/pkgconfig \
${datadir}/aclocal \
${bindir}/*-config"
php.inc:
EXTRA_OECONF_append = " --with-curl=${libdir}/.."
DEPENDS_${PN} += "libcurl-dev libcurl-dev-native"
PHP Staging Directory:
/installeddeps/curl-native
/installeddeps/curl-native.b77f37db31cf2391919a12c5c9774bff
/installeddeps/curl-native.complete
/usr/share/aclocal/libcurl.m4
/usr/bin/curl-config
/usr/bin/crossscripts/curl-config
/usr/bin/curl
/usr/lib/pkgconfig/libcurl.pc
/usr/lib/libcurl.so
/usr/lib/libcurl.a
/usr/lib/libcurl.so.4.4.0
/usr/lib/libcurl.so.4
/usr/include/curl
/usr/include/curl/curl.h
/usr/include/curl/curlrules.h
/usr/include/curl/curlbuild.h
/usr/include/curl/curlver.h
/usr/include/curl/easy.h
According to php manual, PHP/cURL feature is enabled at php configuration stage with --with-curl=[dir] option.
I checked the main recipe include file php.inc and couldn't find such configuration option. So, try creating in your working layer php_%.bbappend file with (or add this directly to the bottom of php.inc to test):
EXTRA_OECONF_append_class-target = " --with-curl=${STAGING_LIBDIR}/.."
DEPENDS_append_class-target = " curl"
Note, that curl package among DEPENDS because it is needed at build stage.
I don't think you need to update curl recipe with PACKAGES and FILES, pkg_config should take care

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException Error in Laravel

I was trying to access http://localhost:8000/phpmyadmin for database in laravel. But it's showing the following error:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Open:
C:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php
$others = $this->checkForAlternateVerbs($request);
if (count($others) > 0) {
return $this->getOtherMethodsRoute($request, $others);
}
throw new NotFoundHttpException;
I used following command to open my server and it automatically open with 8000 port that's why i have to use
http://localhost:8000/phpmyadmin
php artisan serve
So, if anyone know the solution, please reply.
If you have phpmyadmin properly installed and configured on your local, you should just access it from http://localhost/phpmyadmin with or without your laravel application running on http://localhost:8000, that make no difference.
Also, every URI you will try tro access after http://localhost:8000/ will be considered as a route of your laravel application.
Access http://localhost:8000/phpmyadmin involves you have a route like Route::get('/phpmyadmin', /** ... /*);
If you doesn't have phpmyadmin installed and accessible on your local, download it and follow the instructions to make it accessible from your web server.
The php artisan serve command run the PHP built-in server.
It doesn't use your apache (XAMPP) webserver, but the web server provided by php.
See PHP built-in server
Make sure you have a route setup for phpmyadmin in your routes.php
Route::get('/phpmyadmin', function () {
return 'Nothing here';
});
This will not give you the phpmyadmin though.

Categories