web.php 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. use Illuminate\Support\Facades\Redis;
  4. use App\Http\Controllers\PostController;
  5. /*
  6. |--------------------------------------------------------------------------
  7. | Web Routes
  8. |--------------------------------------------------------------------------
  9. |
  10. | Here is where you can register web routes for your application. These
  11. | routes are loaded by the RouteServiceProvider within a group which
  12. | contains the "web" middleware group. Now create something great!
  13. |
  14. */
  15. Route::get('/', function () {
  16. return view('welcome');
  17. });
  18. Route::get('/connection', function () {
  19. dd(\Illuminate\Support\Facades\Redis::connection());
  20. });
  21. Route::get('/site_visits', function () {
  22. return '网站全局访问量:' . \Illuminate\Support\Facades\Redis::get('site_total_visits');
  23. });
  24. Route::get('/posts/popular', [PostController::class, 'popular']);
  25. Route::get('/posts/{post}', [PostController::class, 'show']);
  26. Route::get('/posts/{id}', [PostController::class, 'show'])->where('id', '[0-9]+');