Symfony hosted in heroku with SqlLite error - sqlite

Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: "No route found for "GET http://task-demi.herokuapp.com/api/register": Method Not Allowed (Allow: POST)" at /app/vendor/symfony/http-kernel/EventListener/RouterListener.php line 140
So I have uploaded my Symfony 5 in heroku.
It is working well in localhost,no error ,but after hosting in Heroku I get above error.
I have used SqlLite
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
doctrine_heroku.yaml
doctrine:
dbal:
driver: 'pdo_sqlite'
server_version: '3.15'
How to resolve this?

Did you install symfony/apache-pack. It allows you to access any URL on your application without having to include /index.php in the path.
In order to quickly enable rewriting for the Apache web server, you can install the symfony/apache-pack recipe, which places a suitable .htaccess file into your public/ directory:
composer require symfony/apache-pack
git add composer.json composer.lock symfony.lock public/.htaccess
git commit -m "apache-pack"
Source : Heroku

Related

Can't find /api route with api-platform

I'm beginner, I use Symfony / Composer / MAMP and api-platiform
I have create a new projet in the htdocs folder with the command "composer create-project"
I install api-platform with the command "composer req api"
I good have the file api_platform.yaml api_platform.yaml
But i cant access to /api route on my project
I try different URL like : localhost/project/public/api, localhost/api, localhost/project/api, nothing work
Sorry for my english
Thanks to helping me
It looks like you're missing the .htaccess file. When using Apache you should install the apache-pack with this...
composer require symfony/apache-pack
This will add the .htaccess file to your public folder for the correct rewrite rules as explained in the docs here.

symfony 5 is not serving routes other than /

i am following the tutorial and symfony is not working for routes other than /. I am using a xampp stack to serve html and get a 404 error in the logs. i tried putting the route in routes.yaml and using annotations #Route("/brand/new", name="brand_new").what else should I try?
You are probably missing a .htaccess file which redirects requests to the index.php front controller.
You can install a recommended version of it through a flex recipe:
composer require symfony/apache-pack
Further information: https://symfony.com/doc/current/setup/web_server_configuration.html
i found the answer at Command composer require symfony/apache-pack doesn't create .htaccess file
first do composer remove... then composer require...

setting symfony for local development on herkou

I am trying to set up my symfony 2.8 app for local development.(Following - https://symfony.com/doc/current/deployment/heroku.html)
Added In proc file
web: bin/heroku-php-apache2 web/
Error
bin/sh: vendor/bin/heroku-php-apache2: No such file or directory
Also note , composer.phar config bin-dir is bin
Anyone who can share how they resolved this problem?
First of all, have you tried letting heroku create the Procfile itself? I think lately it was smart enough to work out the root of the Symfony project.
If that doesn't work, maybe that's not the right path, try:
echo 'web: $(composer config bin-dir)/heroku-php-apache2 web/' > Procfile
If none of those work, I'd rather use the heroku information on how to deploy your Symfony app, have a look at this and see if it helps:
https://devcenter.heroku.com/articles/getting-started-with-symfony

symfony2 assets in changed web folder

I'm using Symfony2 in my project and I changed web root ditectory. I followed instructions on this page http://symfony.com/doc/current/cookbook/configuration/override_dir_structure.html. Now my project structure looks like this:
/frontend - the new web root dir
/myproject - the project dir
Then i'm installed and dumped assets
php app/console assets:dump
php app/console assetic:install ../frontend --symlink
Most things works fine. But the problem is that I can't acces to any asset in /bundles directory, Symfony returns error
No route found for "GET /bundles/..."
But I can see my assets in this directory in explorer (symlinks created correctly).
Is your web server configured to follow symlinks? Without knowing which web server you are using, as an example in apache you need to set the FollowSymLinks option. Alternatively, remove the symlink option when doing assets:install.
Also, it's probably just a typo, but you've got the commands for installing assets and dumping assetic a bit muddled in your question - should be something like this:
php app/console assets:install --symlink ../frontend
php app/console assetic:dump -e dev

Symfony 2.2 Deployment Questions

Because of an other problem on my server, I tried to setup a real new project and did this (localhost with xampp on windows):
installed curl
loader composer like told in docs
loader vendors like told in docs
merged app/config-folder
copied src-folder
copied web/bundles/myBundle-folder
After that, I tried the deployment-steps documentation. I skipped uploading the files and editing parameter.yml (it's already configured for localhost).
Than I am running into trouble doing 'B) Update your vendors':
php composer.phar install --optimize-autoloader
This steps remove all my files from the web\bundles\myBundle-folder.
Do I have to tell composer about my bundle? I first thought, that I have to store them somewhere else, but this thread tells me, that I am right?!
The thread you are mentioning is from symfony 1, but you are installing a symfony 2 application.
In web/bundles are your assets installed (css, javascript and images).
Your bundles which will be installed via composer are in your vendors folder.
And your own bundles should be in the src folder.
I think this is a good start to have a look at where to store your files.
Your css, js and images should be stored in a bundle, e.g.:
src/AcmeDemoBundle/Resources/public/css
src/AcmeDemoBundle/Resources/public/js
src/AcmeDemoBundle/Resources/public/images
And then you can install your assets with php app/console assets:install web and they will be pushed into the web/bundles folder.

Resources