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.
Related
I successfully implemented Google's sign-in feature which is running quite nicely on my local machine (Mac, PHP, MySQL) following these instructions. I posted how I implemented this here.
I have recently uploaded the work-in-progress site to a container in a Google Cloud Run environment but this sign-in feature is no longer working. The error log shows: PHP Fatal error: Uncaught Error: Failed opening required '/var/www/html/vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/html/includes/oauth.php:5.
I've take this to mean that the /vendor/... dependencies are either in a different location, or not there at all (I exclude these files from the deployment, though I do include the composer.json file which requires the google/apiclient) and I can't figure out if there is a simple configuration I need to perform to tell the Cloud Run service about the dependency.
I'm getting very lost in the Google documentation. One track suggests that I should abandon this method and move to Google Identity Services Library which would be quite frustrating as I spent quite some effort getting the current method working correctly.
The javascript components work well and produce a pop-up to allow the user to select their Google ID and log in. The callback function works too as the oauth.php file is executed on the server and it outputs to the console the sessionId. It's just the require_once line that's causing the failure.
// oauth.php
<?php
session_start();
error_log("oauth.php SessionId: " . session_id(), 0);
include 'connect.php';
require_once __DIR__ . '/vendor/autoload.php';
$jwt = new \Firebase\JWT\JWT; //Allow for discrepancies between server and auth times
$jwt::$leeway = 100;
$CLIENT_ID = "XXX";
$client = new Google_Client(['client_id' => $CLIENT_ID]); // Specify the CLIENT_ID of the app that accesses the backend
$client->setRedirectUri('postmessage');
$client->addScope("email");
$client->addScope("profile");
if (isset($_POST['idtoken'])){
$id_token = $_POST['idtoken'];
// Code continues to validate and process the user data
}
Has anyone experienced this challenge and found a resource to help with migrating a google sign-in service from a standalone apache-based deployment to Google Cloud Run?
My Dockerfile (which doesn't contain any information about composer. I'm now reading that I need to perform a composer install either within this Dockerfile or within docker-compose):
# Use the official PHP image.
# https://hub.docker.com/_/php
FROM php:8.0-apache
# Configure PHP for Cloud Run.
# Precompile PHP code with opcache.
RUN docker-php-ext-install -j "$(nproc)" opcache
RUN docker-php-ext-install -j "$(nproc)" mysqli
RUN set -ex; \
{ \
echo "; Cloud Run enforces memory & timeouts"; \
echo "memory_limit = -1"; \
echo "max_execution_time = 0"; \
echo "; File upload at Cloud Run network limit"; \
echo "upload_max_filesize = 32M"; \
echo "post_max_size = 32M"; \
echo "; Configure Opcache for Containers"; \
echo "opcache.enable = On"; \
echo "opcache.validate_timestamps = Off"; \
echo "; Configure Opcache Memory (Application-specific)"; \
echo "opcache.memory_consumption = 32"; \
} > "$PHP_INI_DIR/conf.d/cloud-run.ini"
# Copy in custom code from the host machine.
WORKDIR /var/www/html
COPY . ./
# Use the PORT environment variable in Apache configuration files.
# https://cloud.google.com/run/docs/reference/container-contract#port
RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
# Configure PHP for development.
# Switch to the production php.ini for production operations.
# RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# https://github.com/docker-library/docs/blob/master/php/README.md#configuration
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
composer.json:
{
"require": {
"google/apiclient": "^2.11"
}
}
I added the following to the end of my Dockerfile. I added the USER line as I was getting a "An error was encountered loading IAM roles associated with the service acount[sic]." error. This user has the following roles: Cloud Run Admin, Secret Manager, Service Accounts, Cloud Build. I'm still getting build failures, probably because I'm not using the user correctly. I read that composer wants to install as root which causes problems during a cloud build:
FROM composer as builder
WORKDIR /app/
USER XXX#cloudbuild.gserviceaccount.com
COPY composer.* ./
RUN composer install
COPY --from=builder /app/vendor /var/www/html/vendor
I've installed mjml cli using the following command (as described in the mjml documentation):
npm install mjml --save
now if i did node_modules/.bin/mjml in the command line it will run successfully.
the problem is when i use the symfony process component in php i got the following error (even if it's the right path):
The command "/Users/qoraiche/Documents/my-app/node_modules/.bin/mjml" failed. Exit Code: 127(Command not found) Working directory: /Users/qoraicheOS/Documents/my-app/public Output: ================ Error Output: ================ env: node: No such file or directory
Symfony process code:
$process = new Process(base_path('node_modules/.bin/mjml'));
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
By the way i have installed mjml globally as well and try it with no luck.
Try providing the full path to node.js when calling the MJML binary from a Symfony Process().
$process = new Process('/your/path/to/node ' . base_path('node_modules/.bin/mjml'));
I use this method in my own apps. Of course, you will need to provide the input and output files to actually transpile anything.
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.
I'm experimenting with Deployer to deploy Laravel application into shared hosting (using laravel recipe) from my local ~/Code/project_foo.
The point is that when I'm connected to my shared hosting server via ssh, then default php -v version is 5.6.33. I confirmed that I can change php version on fly by calling php70 -v or even whole path like /usr/local/bin/php70 whatever.
The point is that I don't know how to tell deployer to call commands using php70 which is required, otherwise composer install fails.
So in Terminal I'm inside root of the Laravel project and I simply call:
dep deploy
My deploy.php is messy and very simple but this is just a proof of concept. I'm trying to figure out everything and then I will make it look nicer.
I checked the source code of the laravel recipe, and I saw that there is:
{{bin/php}}
but I don't know how to override the value to match what my hosting tells me to use:
/usr/local/bin/php70
Please, give me any hints how to force the script use different PHP version once connected to the remote host / server.
This is whole script:
<?php
namespace Deployer;
require 'recipe/laravel.php';
//env('bin/php', '/usr/local/bin/php70'); // <- I thought that this will work but it doesn't change anything
// Project name
set('application', 'my_project');
// Project repository
set('repository', 'git#github.com:xxx/xxx.git');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
// Shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', []);
// Writable dirs by web server
add('writable_dirs', []);
// Hosts
host('xxx')
->user('xxx')
->set('deploy_path', '/home/slickpl/projects/xxx');
// Tasks
task('build', function () {
run('cd {{release_path}} && build');
});
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
before('deploy:symlink', 'artisan:migrate');
OK, I've found the solution.
I added (after require):
set('bin/php', function () {
return '/usr/local/bin/php70';
});
For anybody who searches for changing Composer's PHP version:
set('bin/composer', function () {
return '/usr/bin/php7.4 /usr/local/bin/composer';
});
There is function locateBinaryPath()
so result is:
set('bin/php', function () {
return locateBinaryPath('php7.4');
});
first found php path and composer path use this
for more information Setting PHP versions in Deployer deployments
find / -type f -name "php" 2>&1 | grep -v "Permission denied"
find / -type f -name "composer" 2>&1 | grep -v "Permission denied"
then
set('bin/composer',
function () {
return 'php_path composer_path';
});
like this
set('bin/composer',
function () {
return '/opt/remi/php73/root/usr/bin/php /usr/bin/composer';
});
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 !