I'm not deathly familiar with Laravel, but it seems like composer require austintoddj/canvas Doesn't seem to supply any artisan file anywhere. The same applies to the various other composer commands I've found. (I.E. composer create-project --prefer-dist austintoddj/canvas blog)
I'm unsure if I'm missing something that is usually a given with deploying Laravel projects or if there's something not working correctly.
No worries, glad you're checking it out!
So, this is a package that fits _in_ a Laravel app. Go ahead and follow the official instructions to get an app up and running, and then follow along with the Canvas installation instructions.
Let me know if you need any more help with it!
Perfect, thank you!
I was able to get canvas itself working and verified I could post and make multiple user accounts, etc. But I also attempted to install Studio and have seemed to hit another snag and I feel as if it might be another simple mishap or configuration error on my part.
UnexpectedValueException
Invalid route action: [Studio\ViewController].
at vendor/laravel/framework/src/Illuminate/Routing/RouteAction.php:91
87â–• */
88â–• protected static function makeInvokable($action)
89â–• {
90â–• if (! method_exists($action, '__invoke')) {
➜ 91▕ throw new UnexpectedValueException("Invalid route action: [{$action}].");
92â–• }
93â–•
94â–• return $action.'@__invoke';
95â–• }
• `Studio\ViewController` was not found: Controller class `Studio\ViewController` for one of your routes was not found. Are you sure this controller exists and is imported correctly?
+8 vendor frames
9 routes/web.php:42
Illuminate\Support\Facades\Facade::__callStatic()
+3 vendor frames
13 routes/web.php:43
Illuminate\Routing\RouteRegistrar::group()
I realize this isn't the repo for studio but I figured since I already had a thread open there was little reason to open another if this is just a config error.
Glad you got it working!
Did the Studio install process succeed like it should?
Yep, it all seemed to install fine from everything I could tell, including npm install and npm run dev
Do you see the proper routes for Studio in the routes/web.php file?
Also, what version of PHP are you currently running this on?
My routes file seems to be populatedt and I'm assuming that it should be fine(?) I'll post it just in case.
Route::get('/', function () {
return view('welcome');
});
Route::namespace('Studio')->prefix(config('studio.path'))->group(function () {
Route::prefix('api')->group(function () {
Route::prefix('posts')->group(function () {
Route::get('/', 'PostController@index');
Route::get('{identifier}/{slug}', 'PostController@show')->middleware('Canvas\Http\Middleware\Session');
});
Route::prefix('tags')->group(function () {
Route::get('/', 'TagController@index');
Route::get('{slug}', 'TagController@show');
});
Route::prefix('topics')->group(function () {
Route::get('/', 'TopicController@index');
Route::get('{slug}', 'TopicController@show');
});
Route::prefix('users')->group(function () {
Route::get('{identifier}', 'UserController@show');
});
});
Route::get('/{view?}', 'ViewController')->where('view', '(.*)')->name('studio');
});
Php version is
PHP 7.4.10 (cli) (built: Sep 9 2020 06:36:14) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies
And then just verifying, the Studio/ViewController does exist, correct?
My apologies, I'm not sure I understand, would this be a line found in a file, or am I looking for a directory. I posted the full web.php file above.
No worries, here to help.
So when installing Studio, you should have a new controller in app/Http/Controllers/Studio/ called ViewController.php. Do you see that file?
Yep! I do see that file there
ViewController.php
<?php
namespace App\Http\Controllers\Studio;
use Illuminate\Http\Request;
class ViewController extends BaseController
{
/**
* Handle the incoming request.
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function __invoke(Request $request)
{
return view('studio.app', [
'scripts' => $this->scriptVariables(),
]);
}
}
Interesting. Ok, could you try running: composer dumpauto
Wonder if it just needs to load the classes.
Running that still gets me the same error with the "Studio\ViewController was not found. . ."
Hm, let me take a look tonight and get back to you.
Awesome, thanks for all of your help with this!
Ok, got it figured out.
Unfortunately, Studio didn't as much upgrade love as Canvas did. Either way, the route entry you listed above:
Route::namespace('Studio')->prefix(config('studio.path'))->group(function () {
should add the namespace like this:
Route::namespace('App\Http\Controllers\Studio')->prefix(config('studio.path'))->group(function () {
Also, change line 41 of resources/js/studio/components/Navbar.vue from this:
<a v-else class="text-muted text-decoration-none ml-3" href="/login">Sign in</a>
to whatever login URL you have for Canvas (defaults to /canvas/login):
<a v-else class="text-muted text-decoration-none ml-3" href="/canvas/login">Sign in</a>
That should fix the issue. I'll get some more fixes up to Studio and get it more on par with Canvas, but don't hesitate to reach out with any more questions!
That seemed to let me start the artisan server and visit Studio. There are still a couple of issues though, I don't see any of my published posts in the landing page nor on the topic page under the assigned topic (though I can see newly created topics and tags.)
Ok, let me take a look and see what I can do.
@Catbirby After digging into this more, I'm going ahead and re-working Studio as a whole.
I'll get this out in the next release, so keep an eye on the repo!
Will do, I look forward to it, and can't wait!
@Catbirby Ok, just pushed a new version that removes Studio altogether and refactors it into an Artisan command within this repo. Check out the installation instructions here and let me know if you run into any problems with it!
I was able to get Canvas updated and the UI installed with no errors, but I'm not really sure where to go from here, like where to configure the path for the frontend or any default paths fo user access.
Scratch that, I was able to find the path to canvas UI in the web.php file. It seems to work great!
So if I were interested in putting the UI on my base domain (which I am) how would I go about doing that
To do that, you'll need to update a few things.
Assuming you're starting from a new Laravel app, remove any existing routes in web.php and put these in their place:
Route::prefix('api')->group(function () {
Route::get('posts', [\App\Http\Controllers\CanvasUiController::class, 'getPosts']);
Route::get('posts/{slug}', [\App\Http\Controllers\CanvasUiController::class, 'showPost'])
->middleware('Canvas\Http\Middleware\Session');
Route::get('tags', [\App\Http\Controllers\CanvasUiController::class, 'getTags']);
Route::get('tags/{slug}', [\App\Http\Controllers\CanvasUiController::class, 'showTag']);
Route::get('tags/{slug}/posts', [\App\Http\Controllers\CanvasUiController::class, 'getPostsForTag']);
Route::get('topics', [\App\Http\Controllers\CanvasUiController::class, 'getTopics']);
Route::get('topics/{slug}', [\App\Http\Controllers\CanvasUiController::class, 'showTopic']);
Route::get('topics/{slug}/posts', [\App\Http\Controllers\CanvasUiController::class, 'getPostsForTopic']);
Route::get('users/{id}', [\App\Http\Controllers\CanvasUiController::class, 'showUser']);
Route::get('users/{id}/posts', [\App\Http\Controllers\CanvasUiController::class, 'getPostsForUser']);
});
Route::get('/{view?}', [\App\Http\Controllers\CanvasUiController::class, 'index'])->where('view', '(.*)')->name('canvas-ui');
Change line 48 of js/canvas-ui/routes.js from:
redirect: '/canvas-ui',
to this:
redirect: '/',
Change line 25 of js/canvas-ui/mixins/base.js from this:
instance.defaults.baseURL = '/canvas-ui';
to this:
instance.defaults.baseURL = '/';
Then, re-compile the assets:
npm run dev
Perfect, that worked like a charm, thanks
You're welcome! Hope it serves you well!