symfony 4 application not updated in homestead/vagrant - php

I'm using Homestead for symfony 4 application.
Everthings work with symfony web server but,
homestead not recognized controller changes.
For example:
I create /test route in TestController but homestead
No route found for "GET /test"
I run cache:clear and remove var directory but nothing changed.
I'm using arch linux and homestead/virtualbox.
Can anyone give me a help about that?
Thanks,

I use a custom vagrant script to build my VM but I have had this issue a few times - this is how I solved it:
src/Kernel.php
public function getCacheDir ()
{
//return $this->getProjectDir().'/var/cache/'.$this->environment;
return '/var/tmp/cache/' . $this->environment;
}
public function getLogDir ()
{
//return $this->getProjectDir() . '/var/log';
return '/var/tmp/log';
}
Also read https://symfony.com/doc/current/configuration/override_dir_structure.html#override-cache-dir

I fixed my problem.
I recreated homestead box and left only one site in homestead.yaml file.
sites:
- map: sf18.app
to: /home/vagrant/code/sf18/public
type: symfony4
I believe it's related homestead.yaml and homestead-17 box.

Related

404 error when adding a different route - Laravel dead simple routing

I've been laraveling for 5 months now but I reformatted ubuntu and installed Laravel, this time, it's Laravel 7 instead of Laravel 6. My problem is simple routing giving an error. It's so dead simple you might think I'm a stupid beginner.
In my Web.php
Route::get('/about', function () {
return view('welcome');
});
Route::get('/', function () {
return view('welcome');
});
I also tried using a controller that returns a view and just a simple "string" in Web.php
Route::get('/about', 'UserController#index');
Typing http://localhost/about in the address bar in chrome causes 404 error.
As you can see, there should be no problem returning the same view('welcome'), even if I return a simple return "TEST";, results are the same.
I tried downgrading to Laravel 6 by deleting vendor, changing the Laravel v6 in composer.json and running composer install but still the same, so I think it's not the version.
This has never happened to me before even when I first started with Laravel 6 five months ago and it's a totally fresh project.
enable rewrite_mode of Apache server and restart Apache server it will solve the issue.
Run server with php artisan serve
and then try http://localhost:8000/about hope it will fix your problem
OR
Simply use http://localhost/project/about

Laravel (ver 6) php artisan route:list return "Target class does not exist" error with production environment (worked fine in local environment)

I'm using laravel 6 for BE and vuejs for FE. Wtih my local environment ( built on xampp server ), everything was fine. But, when I deployed the app to the server(Lamp server with ubuntu 18.04), I got the following error when I tried to run "php artisan route:list".
Illuminate\Contracts\Container\BindingResolutionException : Target class [App\Http\Controllers\Masterdata\CountryController] does not exist.
at /var/www/html/performance.goautobot.chat/public_html/performance/vendor/laravel/framework/src/Illuminate/Container/Container.php:806
try {
$reflector = new ReflectionClass($concrete);
} catch (ReflectionException $e) {
throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
}
And some APIs are not working. The weird part is both "Roles" and "Countries" have exactly the same structure as the following but only apis related to "Roles" are working got "BindingResolutionException" error when I tried with Postman.
Route::group(['middleware' => 'auth:api'], function () {
// Countries
Route::get('masterdata/countries', 'Masterdata\CountryController#index');
// Roles
Route::get('masterdata/roles', 'Masterdata\RoleController#index');
}
I tried to solve it by running the commands like "composer dump-autoload" and "php artisan config:cache" but it didn't fix the problem. Also, tried to remove the project folder and made a new installation and deployment.
Please let me know how to fix the issue. Thank you so much in advance.
I had a similar issue with HomeController, then I checked the routes in the web.php file,
I found it was like the following
Route::get('/', 'HomeController#index');
Then I changed this to the following according to the directory where the Homecontoller resides
Route::get('/', 'App\Http\Controllers\HomeController#index');
after that, it worked correctly.
So Please check your controller directory,
if your controller directory is "App\Http\Controllers\Masterdata\CountryController" then add this in the route. it will be like following
Route::get('/', 'App\Http\Controllers\Masterdata\CountryController');
I tried to explain according to my scenario,
Please let me know if this helps and please pardon me if I have got something wrong

Vagrant & Symfony 3.3: Failed to remove directory

Trying to set up a Symfony 3.3 environment with Flex. Currently, when trying to require some packages like the following:
composer req annotations security orm template asset validator
Everything goes well, except on cache:clear I'm getting the following errors:
!! [Symfony\Component\Filesystem\Exception\IOException]
!! Failed to remove directory "/home/vagrant/Code/multi-user-gallery-blog/var/
!! cache/loca~/pools": rmdir(/home/vagrant/Code/multi-user-gallery-blog/var/ca
!! che/loca~/pools): Directory not empty.
I already tried to remove the folders manually, but those are generated automatically in the installation process, and then Symfony cannot remove them.
I'm running this on Vagrant Homestead.
Any idea on how can I solve this problem?
This is an issue with the way Vagrant/VirtualBox maps shared folders between the host and guest machines. In Symfony projects, the cache directory is typically placed within the project directory that gets synced from the host machine.
We can change the cache directory to use a location within the guest machine's filesystem to avoid these problems by adding an override method to the app/AppKernel.php class:
class AppKernel extends Kernel
{
...
public function getCacheDir()
{
if ($this->environment === 'local') {
return '/tmp/symfony/cache';
}
return parent::getCacheDir();
}
}
The example above demonstrates how we can set a custom cache directory for local development environments while retaining the default behavior for production. /tmp/symfony/cache is just an example. We can choose a location anywhere on the guest machine's filesystem that the application has permission to write to. Replace 'local' with the name of the environment the project uses for development.
See my comment to the accepted answer, here is the code:
public function getCacheDir()
{
if (in_array($this->environment, ['dev', 'test'])) {
return '/tmp/cache/' . $this->environment;
}
return parent::getCacheDir();
}
public function getLogDir()
{
if (in_array($this->environment, ['dev', 'test'])) {
return '/var/log/symfony/logs';
}
return parent::getLogDir();
}

Laravel 5.1 View not found

this seems to be an issue that pops up every now and then within Laravel. I was writing a CRUD controller with a view to go with it, however upon testing I got the InvalidArgumentException in FileViewFinder.php line 137: View [bookingcrud.index] not found error. Here is my code:
routes.php:
Route::resource('bookingcrud', 'BookingsCrudController');
BookingsCrudController.php
use uasc\Http\Requests;
use uasc\Http\Requests\CrudCreateRequest;
use uasc\Http\Requests\CrudUpdateRequest;
use uasc\Http\Controllers\Controller;
use Auth;
use DB;
use Illuminate\Pagination\Paginator;
use Illuminate\Http\Request;
class BookingsCrudController extends Controller {
public function index()
{
if (!Auth::check() || Auth::user()->authority < 1) {
return redirect('/login');
}
$raw = "select * from bookings";
$bookings = DB::select($raw);
$paginatedBookings = new Paginator($bookings, 1);
return view('bookingcrud.index')->with('bookings', $paginatedBookings);
}
}
And a view located in ~/laravel/resources/views/bookingcrud/index.blade.php
No matter what is in this view file whether its markup from a working view or just the word "cheese" i will always get:
InvalidArgumentException in FileViewFinder.php line 140:
View [bookingcrud.index] not found.
I tested the same view in a known working controller and got the same error however I tested a known working view on the same CRUD controller and it worked. I have also tried changing the directory of the view and renaming it but i'll get the same error with the "View [bookingcrud.index]" changing appropriately. I made sure the permissions of the file and directories were full for testing.
Since first getting the error I have upgraded to 5.1.1 from 5.0.26 (which is the version the error originated on for me) and ran composer update. Also from looking at threads with the same error I have also ran artisan config:clear
I am developing on Windows 8.1 with Homestead 2.0.17 deployed with Virtual Box.
Any help would much appriciated at this point it is doing my head in.
Please use terminal
homestead ssh > Press Enter
vagrant#homestead cd /Path_of_Your_Project/
vagrant#homestead:~/Path_of_Your_project php artisan cache:clear
vagrant#homestead:~/Path_of_Your_project php artisan config:cache
Sorry about my English
Turns out I had spelt blade incorrectly, took a second pair of eyes to notice it though.
$ ls resources/views/crud/booking/
crud.balde.php index.balde.php
Was definitely a lesson to always double check the small things when debugging.
Thanks for the help.
For someone who don't have SSH Access, There are two ways to solve this problem.
If you don't have any plugin of default Laravel package,
First, Just remove the bootstrap/cache/config.php to solved the file,
OR
If you have any plugin of default Laravel package,
Change all related path mentioned bootstrap/cache/config.php into the exact path which allocated the laravel project.
Remember that Linux is case sensitive!
I had something like this:
return view('MyView', $data);
And it was working on my environment (Mac OS), but not on the deployment server (Ubuntu)!

CakePHP 2.1 bake test app and failed

I download cakephp 2.1 from the official website. When I copied files to my www directory on Windows 7 64bit, (using WAMP 2.2 with PHP 5.3.8), and configured path to link to cake bake.bat in console folder I have problem. When I run cmd and typing cake bake testapp (to generate some test app and test new futures) I see in console strength error:
File app/View\Pages\home.ctp exists
Do you want to overwrite?
I answered y. The bake app is ready but If I type my localhost in my browser I see
The action index is not defined in controller AppController
so I type manual pages to url I see 404!
Please help me because I want start a new project with new CakePHP 2.1 not 2.0.6...
This issue is fixed.
If you still getting error comment the following code in C:\wamp\www\cake\lib\Cake\Console\Command\Task\ProjectTask.php file
if ($this->createHome($path)) {
$this->out(__d('cake_console', ' * Welcome page created'));
} else {
$this->err(__d('cake_console', 'The Welcome page was <error>NOT</error> created'));
$success = false;
}
NOTE: C:\wamp\www\cake - This is my cake liberary path, change yours if its different.

Categories