symfony 4 NotFoundHttpException by image in public folder - symfony

creating symfony project
composer create-project symfony/skeleton cars
cd cars
php -S 127.0.0.1:8000 public/index.php
composer require annotations
composer require twig
composer require asset
Creating Page
public/image/seta.png
templates/number.html.twig
<img src="{{asset('image/seta.png')}}">
src/Controller/CarController.php
/**
* #Route("/")
*/
public function number()
{
return $this->render('number.html.twig');
}
Why does browser show:
Symfony Exception > ResourceNotFoundException > NotFoundHttpException
No route found for "GET /image/seta.png" (from "http://localhost:8000/")
(Web page doesn't show seta.png)

The issue you're having is that the browser can't find the image, as in the path you have given it doesn't exist or isn't accessible to the client. That's what your error is indicating.
You need to confirm that you can access the image through your browser first. If you can't, then I would suggest you start to look at it's location and whether the path you're using corresponds to it's location.
If you're sure the file path is fine and the image exists and that it's named correctly corresponding to what you're calling it, you should then check the file and folder permissions where the image is located so it's accessible.

Please check the HTML, this code rendered.
<img src="{{asset('image/seta.png')}}">

change
php -S 127.0.0.1:8000 public/index.php
to
php -S 127.0.0.1:8000 -t public

Ronald2g is right, you can also try with the web server bundle:
composer require server --dev
and:
php bin/console server:start

Not sure if it can help you, but this might help others having a similar issue.
I had the same issue when I was mistakenly using an internal port number (port 42595 in the example below) given in the command line feedback, instead of port 8000:
$ symfony server:start --no-tls
Feb 25 12:25:30 |DEBUG| PHP Reloading PHP versions
Feb 25 12:25:31 |DEBUG| PHP Using PHP version 7.4.2 (from default version in $PATH)
Feb 25 12:25:31 |INFO | PHP listening path="/usr/bin/php7.4" php="7.4.2" port=42595
Feb 25 12:25:31 |DEBUG| PHP started
Feb 25 12:25:31 |DEBUG| PHP PHP 7.4.2 Development Server (http://127.0.0.1:42595) started
[OK] Web server listening on 8000 http://127.0.0.1:8000 (PHP CLI 7.4.2)

Related

Symfony 4, when i ope public folder i have blank page after deployment

I have developed an application in Symfony 4. The application works perfectly in localhost, with the command php -S 127.0.0.1:8000 -t public I see the application in localhost: 8000, but if I access localhost / nameproject / public I have a page white. I ran the commands composer install --no - dev --optimize - autoloader, export APP_ENV = prod, php bin / console cache: clear --env = prod --no - debug and composer require symfony / apache - pack. Can someone help me?
I found the error, with php -v I return the 7.1.14 version, but with phpinfo () I found that I have in the php php version 5.6! I hope my experience can be useful to someone!

Cannot install Jenkins: no valid crumb

I've just installed Jenkins on a google cloud vm and configured nginx to point at 8080. I can enter the initial admin password and then i get to the screen where i can select plugins. When i click on "install suggested plugins" an error appears:
No valid crumb was included in this request
I started Jenkins with the command:
java -Dhudson.security.csrf.requestfield=Jenkins-Crumb -jar jenkins.war
stdout says:
INFO: Session node016ikde2z4paqem02o7wos0rgd1 already being invalidated
Nov 02, 2017 7:57:44 PM hudson.security.csrf.CrumbFilter doFilter
WARNING: Found invalid crumb 27d19a27be31d1d5703128b635b60c3b. Will
check remaining parameters for a valid one...
Nov 02, 2017 7:57:44 PM hudson.security.csrf.CrumbFilter doFilter
WARNING: No valid crumb was included in request for
/pluginManager/installPlugins. Returning 403.
does anybody know how i can either disable CSRF or include a valid crumb in my request? I can generate a valid crumb by running:
$ curl -u "admin:ebdcf2fcf6f74ee8b4ec907a1486ml?xpath=concat(//crumbRequestField,":",//crumb)'
Jenkins-Crumb:ef6250c9afe294555e20f1b9ab875261
but i don't know what to do with it after that.
Many thanks!
To Disable CSRF (although this is not recommended), follow the below 3 steps:
Log in to Jenkins as an Administrator
GOTO: Jenkins > Manage Jenkins > Configure Global Security and enable Prevent
Cross Site Request Forgery exploits
Uncheck this option
Mention the version of the Jenkins you are using to suggest on how to provide a valid crumb in your request.

Wordpress - The ssh2 PHP extension is not available

I use SSH keys in my wp-config since a long time. Updates, plugin installation and removal, all worked well. After the last apt-get update wp is asking for the FTP password when I try to install for example a plugin.
There was no change done to the wp installation nor the file or directory permissions. I did not update wp either.
define('FTP_PUBKEY','/home/wp-user/wp_rsa.pub');
define('FTP_PRIKEY','/home/wp-user/wp_rsa');
define('FTP_USER','wp-user'); define('FTP_PASS','');
define('FTP_HOST','127.0.0.1:22');
Ubuntu 14.04
WORDPRESS VERSION: 4.7.6
PHP VERSION: 5.5.9-1ubuntu4.22
WEB SERVER INFO: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f
EDIT:
I added below to my wp-config to see if it changes something.
define('FS_METHOD', 'ssh2');
No I'm getting a different error message in the WP backend:
The ssh2 PHP extension is not available
...but ssh2 is installed and loaded:
# php -m |grep ssh2
ssh2
Seems to be a bug in libssh2-php...
https://bugs.launchpad.net/ubuntu/+source/php-ssh2/+bug/1617294
Installing the WP plugin below allows me again to install/update as before.
https://en-ca.wordpress.org/plugins/ssh-sftp-updater-support/#description

HHVM not working with nginx

I try use HHVM with nginx in server CentOS 6.5 64bits but it's not working
hhvm --mode server -vServer.Type=fastcgi -vServer.Port=9000 -user nginx
Quote from HHVM's log:
Failed to initialize central HHBC repository: Failed to open /var/log/hhvm/.hhvm.hhbc: 14 - unable to open database file
Failed to open /var/www/.hhvm.hhbc: 14 - unable to open database file
Does someone know what to do in this situation ?
Two things here :
You're mentionning /var/log/hhvm/.hhvm.hhbc and /var/www/hhvm/.hhvm.hhbc .. is this a typo ? Can you give us the content of your server.hdf and config.hdf files ?
The folder /var/log/hhvm must be writeable by the account being used to run the webserver (ie nginx)
(On a side note, I guess it's --userand not -user)

Redmine under sub-directory on nginx

My vhost configuration: http://pastebin.com/ZyXUmQtx (only one domain on this installation)
I've been racking my head and Google for a solution the last two days and can't quite seem to come up with a solution that works.
My setup (from the above configuration):
IP.Board 3.4 installation in %root_domain%/forums/
IP.Content 2.3 installation in %root_domain/forums/ (with external access index.php on the top-level)
Redmine 2.2.2 install at /usr/share/redmine (this is working because Thin is running and there are no errors in either log file)
Stale phpMyAdmin configuration at /usr/share/phpmyadmin/ that also kinda doesn't load html/css properly.
Symlink to /usr/share/redmine/public to /srv/www/tiberian-genesis.net/public_html/redmine
I'm trying to get redmine setup to run under %root_domain%/redmine/, but I keep getting a 404 page from my IP.Content installation.
Accessing it takes me to the url: /redmine/login?back_url=http://redmine_thin_servers/redmine/ (which now that notice it, it seems to not like my upstream...)
In case someone requests the Thin configuration file:
---
pid: /var/run/thin/redmine.pid
group: tgmod
prefix: /redmine
timeout: 30
log: /var/log/thin/redmine.log
max_conns: 1024
require: []
max_persistent_conns: 512
environment: production
user: tgmod
servers: 1
daemonize: true
chdir: /usr/share/redmine
socket: /var/run/thin/redmine.sock
I'm out of ideas here.
Thanks in advance!
I just ended up setting it up on a sub-domain. I wanted to try to proxy it on a sub-directory, but my main website kept interfering with the rules.

Resources